TV / js /sha256.js
samlax12's picture
Upload 30 files
7eff83b verified
raw
history blame contribute delete
307 Bytes
export async function sha256(message) {
const msgBuffer = new TextEncoder().encode(message);
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
const hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
}