From 2433cfb0afa513b03749f5ad4bac57e84ab4e147 Mon Sep 17 00:00:00 2001 From: "nate@necloud.us" Date: Wed, 2 Jul 2025 10:40:39 -0400 Subject: [PATCH] login update --- public/index.html | 3 ++- public/script.js | 14 ++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/public/index.html b/public/index.html index 20f6fb9..7eaf5c7 100644 --- a/public/index.html +++ b/public/index.html @@ -90,7 +90,8 @@ - + + \ No newline at end of file diff --git a/public/script.js b/public/script.js index c647363..ec9f5c3 100644 --- a/public/script.js +++ b/public/script.js @@ -12,19 +12,17 @@ async function loadUsers() { } // 🔐 Password hashing -async function hashPassword(password) { - const msgUint8 = new TextEncoder().encode(password) - const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8) - return Array.from(new Uint8Array(hashBuffer)) - .map(b => b.toString(16).padStart(2, '0')) - .join('') +function hashPassword(password) { + const shaObj = new jsSHA("SHA-256", "TEXT") + shaObj.update(password) + return shaObj.getHash("HEX") } // 👤 Login async function verifyLogin() { const uname = document.getElementById('username').value.trim() const pw = document.getElementById('password').value - const hash = await hashPassword(pw) + const hash = hashPassword(pw) const msg = document.getElementById('loginMessage') const user = users.find(u => u.username === uname && u.hash === hash) @@ -101,7 +99,7 @@ async function addNewUser() { return } - const hash = await hashPassword(password) + const hash = hashPassword(password) await saveUserToServer(username, hash, role) msg.textContent = `✅ User "${username}" added to server.`