Skip to content

TypeScript API / laikacms/crypto / constantTimeEqual

Function: constantTimeEqual() ​

ts
function constantTimeEqual(a, b): Promise<boolean>;

Constant-time string comparison to prevent timing attacks. Uses HMAC comparison - if two values produce the same HMAC with the same key, they are equal.

Parameters ​

ParameterTypeDescription
astringFirst string to compare
bstringSecond string to compare

Returns ​

Promise<boolean>

true if strings are equal, false otherwise

Released under the MIT License.