File
Blob: worker/src/server/crypto.ts
| 1 | export async function digest(value: string): Promise<string> { |
| 2 | const bytes = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(value)); |
| 3 | return Array.from(new Uint8Array(bytes), (byte) => byte.toString(16).padStart(2, '0')).join(''); |
| 4 | } |
| 5 | export async function equal(a: string, b: string): Promise<boolean> { |
| 6 | return (await digest(a)) === (await digest(b)); |
| 7 | } |