MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / secureCompare

Function secureCompare

packages/utilities/src/password.ts:13–30  ·  view source on GitHub ↗
(a: string, b: string)

Source from the content-addressed store, hash-verified

11}
12
13export function secureCompare(a: string, b: string): boolean {
14 if (
15 typeof a !== 'string' ||
16 typeof b !== 'string' ||
17 !a ||
18 !b ||
19 a.length !== b.length
20 )
21 return false;
22
23 const buffer1 = Buffer.from(a);
24 const buffer2 = Buffer.from(b);
25 try {
26 return timingSafeEqual(buffer1, buffer2);
27 } catch (exception) {
28 return false;
29 }
30}

Callers 3

password.spec.tsFile · 0.90
createFunction · 0.90
authorizeMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected