sameText
uses node:crypto
Whether two strings are the same, taking as long whatever they differ in.
import { timingSafeEqual } from "node:crypto"; export function sameText(a: string, b: string): boolean { const x = Buffer.from(a); const y = Buffer.from(b); return x.length === y.length && timingSafeEqual(x, y); }