Skip to content
File

Blob: worker/src/server/crypto.ts

typescript8 lines
1export 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}
5export async function equal(a: string, b: string): Promise<boolean> {
6 return (await digest(a)) === (await digest(b));
7}