This function is based on a constant-time algorithm.
Returns true if a
is equal to b
, without leaking timing information that
would allow an attacker to guess one of the values. This is suitable for
comparing HMAC digests or secret values like authentication cookies or capability urls.
a
and b
must both be Buffer
s, TypedArray
s, or DataView
s, and they
must have the same byte length. An error is thrown if a
and b
have
different byte lengths.
If at least one of a
and b
is a TypedArray
with more than one byte per
entry, such as Uint16Array
, the result will be computed using the platform
byte order.
Use of crypto.timingSafeEqual
does not guarantee that the surrounding code
is timing-safe. Care should be taken to ensure that the surrounding code does
not introduce timing vulnerabilities.
Generated using TypeDoc
This function is based on a constant-time algorithm. Returns true if
a
is equal tob
, without leaking timing information that would allow an attacker to guess one of the values. This is suitable for comparing HMAC digests or secret values like authentication cookies or capability urls.a
andb
must both beBuffer
s,TypedArray
s, orDataView
s, and they must have the same byte length. An error is thrown ifa
andb
have different byte lengths.If at least one of
a
andb
is aTypedArray
with more than one byte per entry, such asUint16Array
, the result will be computed using the platform byte order.Use of
crypto.timingSafeEqual
does not guarantee that the surrounding code is timing-safe. Care should be taken to ensure that the surrounding code does not introduce timing vulnerabilities.