Skip to content

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.

string

First string to compare.

string

Second string to compare.

boolean

true if the strings are identical.

import { timingSafeEqual } from "@homegrower-club/stoma";
// Use in API key validators to prevent timing attacks
const isValid = timingSafeEqual(providedKey, storedKey);