crypto.ts 290 B

12345678
  1. import { timingSafeEqual } from "node:crypto"
  2. export function safeEqual(a: string, b: string): boolean {
  3. const encoder = new TextEncoder()
  4. const aBytes = encoder.encode(a)
  5. const bBytes = encoder.encode(b)
  6. return aBytes.length === bBytes.length && timingSafeEqual(aBytes, bBytes)
  7. }