Returns true if two HMAC digests are equal. Uses constant-time comparison to avoid leaking timing information.
Example:
const receivedDigest = ... const realDigest = hmac(SHA256, key, data); if (!equal(receivedDigest, realDigest)) { throw new Error("Authentication error"); }
Returns true if a and b are of equal non-zero length, and their contents are equal, or false otherwise.
Note that unlike in compare() zero-length inputs are considered not equal, so this function will return false.
Returns true if two HMAC digests are equal. Uses constant-time comparison to avoid leaking timing information.
Example:
const receivedDigest = ... const realDigest = hmac(SHA256, key, data); if (!equal(receivedDigest, realDigest)) { throw new Error("Authentication error"); }