0
我只是想在HTML/js中製作一個簡單的登錄示例。 當然我會將密碼輸出到數據庫中。但是,對於一個簡單的測試,我嘗試了這些:登錄JavaScript - 密碼編碼
function validate(){
var username = document.getElementById("username").value;
var pwd = document.getElementById("pwd").value;
var cryptpwd = CryptoJS.SHA1(pwd);
alert(cryptpwd);
if (username === "Paili" && cryptpwd === "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"){
alert("Login sucess!");
alert(cryptpwd);
window.location = "seite1.html";
return false;
}
else{
alert("something went wrong");
prompt(username,cryptpwd);
return false;
}
}
它總是進入其他人,但我cryptpwd和用戶名的輸出是正確的。 比我查詢不cryptpwd但pwd和它的工作。
輸出:
爲什麼它不工作?
嘗試'的console.log(typeof運算cryptpwd);'和'的console.log(typeof運算的用戶名);!' - 如果type =比字符串,這是關鍵。 – vitozev