mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-30 00:00:29 +00:00
9 lines
290 B
TypeScript
9 lines
290 B
TypeScript
import { timingSafeEqual } from "node:crypto"
|
|
|
|
export function safeEqual(a: string, b: string): boolean {
|
|
const encoder = new TextEncoder()
|
|
const aBytes = encoder.encode(a)
|
|
const bBytes = encoder.encode(b)
|
|
return aBytes.length === bBytes.length && timingSafeEqual(aBytes, bBytes)
|
|
}
|