This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function hashPassword(password) { | |
const passwordBuffer = new TextEncoder().encode(password); | |
const hashBuffer = await crypto.subtle.digest('SHA-256', passwordBuffer); | |
const hashArray = Array.from(new Uint8Array(hashBuffer)); | |
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); | |
return hashHex; | |
} | |
function generateRandomPassword(length) { | |
const charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; |