在制作密码数据库时需要帮助



我到处找过,但找不到答案。如果有必要,我会更改我的代码,但我希望也不会更改,所以如果你能用 JavaScript 给我一个答案,那就太好了。我正在尝试为此代码创建一个密码数据库;

<!DOCTYPE html> <html lang="en"> <head>   <title>login2</title>   <meta charset="utf-8" /> </head> <body> <input class="textBox" id="pass" type="password" maxlength="30" required/> <button type="button" onclick="a()">Login</button> <script>
    function a() {
        var i = document.getElementById('pass').value;
        if (i == "1234") {
            window.location = "in.html";
        } 
        else {
            window.location = "index.html";
        }
    } </script> </body> </html>

我想这样做,而不是说if (i == "1234)我可以从外部数据库中获取一个带有密码列表的值。如果可以,请告诉我如何修改内容!

谢谢,请帮忙!

我建议做的,过去所做的是将哈希存储在内存中而不是密码中。您可以实现 Joseph Myers 的 MD5 脚本版本,然后修改 <script> 标记的内容以匹配以下内容:

var i = document.getElementById('pass').value;
if (md5(i) == "##MD5ofExpectedPassword##") {
    window.location = i+".html"; // Change the name of the page to the password
} else {
    window.location = "index.html";
}

最新更新