需要帮助制作密码数据库

时间:2015-01-05 20:29:56

标签: javascript database html5 login

我到处寻找但找不到答案。如果必须的话,我会更改我的代码,但我希望不会有,所以如果你能用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)我可以从外部数据库中获取一个带有密码列表的值。 如果可以,请告诉我如何修改内容!

谢谢,请帮帮忙!

1 个答案:

答案 0 :(得分:0)

我建议做什么,过去做过的是将哈希值存储在内存而不是密码中。您可以实现Joseph Myers's MD5 script的版本,然后修改<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";
}
相关问题