chat-ui / src /lib /utils /sha256.ts
coyotte508's picture
coyotte508 HF staff
♻️ Duplicate convos in DB when they are shared (#44)
76d4779 unverified
raw
history blame
No virus
342 Bytes
export async function sha256(input: string): Promise<string> {
const utf8 = new TextEncoder().encode(input);
const hashBuffer = await crypto.subtle.digest('SHA-256', utf8);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray.map((bytes) => bytes.toString(16).padStart(2, '0')).join('');
return hashHex;
}