mirror of
https://github.com/logos-messaging/lab.waku.org.git
synced 2026-05-12 05:49:28 +00:00
13 lines
465 B
TypeScript
13 lines
465 B
TypeScript
export async function sha256(text: string): Promise<string> {
|
|
const encoder = new TextEncoder();
|
|
const data = encoder.encode(text);
|
|
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;
|
|
}
|
|
|
|
export function generateRandomNumber(): string {
|
|
return Math.random().toString();
|
|
}
|