10 lines
333 B
TypeScript
10 lines
333 B
TypeScript
export async function hash(message: string) {
|
|
const data = new TextEncoder().encode(message);
|
|
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join(
|
|
"",
|
|
);
|
|
return hashHex;
|
|
}
|