timingSafeEqual
timingSafeEqual(
a,b):boolean
Defined in: src/utils/timing-safe.ts:30
Compare two strings in constant time.
Returns true if a and b are identical, false otherwise.
The comparison always examines every byte of the longer string,
preventing timing side-channels that leak prefix information.
Parameters
Section titled “Parameters”string
First string to compare.
string
Second string to compare.
Returns
Section titled “Returns”boolean
true if the strings are identical.
Example
Section titled “Example”import { timingSafeEqual } from "@homegrower-club/stoma";
// Use in API key validators to prevent timing attacksconst isValid = timingSafeEqual(providedKey, storedKey);