我正在開發一個登錄系統,您可以在客戶端散列密碼,然后將其發送到服務器。我已經獲取了密碼并對其進行了哈希處理,現在我只需要將其插入數據庫和/或比較登錄。 <form action="javascript:;" onsubmit="return changeFormLogin()"> <p>Email</p> <input id="username" type="email" name="username" placeholder="Enter Email" required> <p>Password</p> <input id="getPass" type="password" name="password" placeholder="??????" required> <input type="submit" name="login" value="Sign In"> <p id="demo"></p> </form> <script src="https://cdnjs.cloudflare.com/ajax/libs/js-sha256/0.9.0/sha256.min.js" ></script> <script> function changeFormLogin() { var pass = document.getElementById('getPass').value; var username = document.getElementById('username').value; var getSalt = 123566; var hashpass = sha256(pass+pass); console.log(hashpass); var tmp = validateLogin(hashpass); if(tmp ==1){ //Welcome the user back, and load new form } else{ //Tell them to try again, notify them. } document.getElementById("demo").innerHTML = hashpass; //Used for testing return true; }
將 Javascript 變量傳遞給 PHP
喵喵時光機
2021-10-29 15:13:23