10 lines
271 B
TypeScript
10 lines
271 B
TypeScript
export async function sha256(input: string): Promise<string> {
|
|
const hash = await globalThis.crypto.subtle.digest(
|
|
'SHA-256',
|
|
new TextEncoder().encode(input),
|
|
);
|
|
return Array.from(new Uint8Array(hash))
|
|
.map((b) => b.toString(16).padStart(2, '0'))
|
|
.join('');
|
|
}
|