This commit is contained in:
10
lib/utils/crypto.ts
Normal file
10
lib/utils/crypto.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { timingSafeEqual } from 'crypto'
|
||||
|
||||
export function constantTimeEqual(a: string, b: string) {
|
||||
const bufA = Buffer.from(a)
|
||||
const bufB = Buffer.from(b)
|
||||
|
||||
if (bufA.length !== bufB.length) return false
|
||||
|
||||
return timingSafeEqual(bufA, bufB)
|
||||
}
|
||||
Reference in New Issue
Block a user