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