feat: add gravatar profile picture integration

This commit is contained in:
Elias Schneider
2024-10-02 10:02:28 +02:00
parent d02d8931a0
commit 365734ec5d
3 changed files with 22 additions and 2 deletions

View File

@@ -0,0 +1,7 @@
export async function createSHA256hash(input: string) {
const msgUint8 = new TextEncoder().encode(input); // encode as (utf-8) Uint8Array
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8); // hash the message
const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string
return hashHex;
}