30ba3fcca7
* Backend infrastructure * New backend configuration work * Factor out KV prefixing * Don't put assets in the manifest cache * Removed fancy authentication stuff * Documentation updates
14 lines
443 B
TypeScript
14 lines
443 B
TypeScript
export async function hashSHA256(message: string): Promise<string> {
|
|
// Transform the string into an ArrayBuffer
|
|
const encoder = new TextEncoder();
|
|
const data = encoder.encode(message);
|
|
|
|
// Generate the hash
|
|
const hashBuffer = await window.crypto.subtle.digest("SHA-256", data);
|
|
|
|
// Transform the hash into a hex string
|
|
return Array.from(new Uint8Array(hashBuffer)).map((b) =>
|
|
b.toString(16).padStart(2, "0")
|
|
).join("");
|
|
}
|