Constant-time equality of two strings or two byte sequences. Pure JS, so it
works where node:crypto is missing.
Two strings are compared code unit by code unit, so the result is exactly
a === b. When either side is bytes (a Uint8Array or an ArrayBuffer), a
string on the other side is compared as its UTF-8 bytes (an unpaired
surrogate encodes as U+FFFD there). Any other input throws a TypeError.
Returns false without comparing when the lengths differ or either side is
empty: an empty signature must never verify. For equal lengths, the time
taken depends only on the length, not on where the inputs differ.
Constant-time equality of two strings or two byte sequences. Pure JS, so it works where
node:cryptois missing.Two strings are compared code unit by code unit, so the result is exactly
a === b. When either side is bytes (aUint8Arrayor anArrayBuffer), a string on the other side is compared as its UTF-8 bytes (an unpaired surrogate encodes as U+FFFD there). Any other input throws aTypeError.Returns
falsewithout comparing when the lengths differ or either side is empty: an empty signature must never verify. For equal lengths, the time taken depends only on the length, not on where the inputs differ.