【问题标题】:Validate password in form with encrypted password in database using Hash sha-512使用哈希 sha-512 在数据库中使用加密密码验证表单中的密码
【发布时间】:2012-03-20 06:56:34
【问题描述】:

使用哈希 SHA-512 在数据库中使用加密密码验证表单中的密码我正在尝试做的是专门用于更改密码表单。

我可以验证表单和数据库中的密码是否未加密...但是我无法验证输入的密码是否等于数据库密码,因为输入的密码仍然是正常形式,并且数据库中的密码是加密的。

我想使用jQuery验证功能......但是在提交之前如何通过使用数据库加密输入的密码来解决。

【问题讨论】:

    标签: jquery encryption passwords password-encryption


    【解决方案1】:
    function Validate(data)
    {
      if(data==true)
      {
       //submit the form
      }
      else
      {
       //dont submit the form. Throw an error/alert
       return false;
      }
    }
    
    //when the form is submitted
    $("#yourForm").submit(function()
    {
    var p=$("#oldPassword").val();
    $.post("validate.php",{oldpass:p},Validate);
    });
    

    PHP 部分 (validate.php)

    <?php
    
    $oldpassword=$_POST['oldpass'];
    
    //encrypt $oldpassword to md5 or anything as per your requirement
    //and compare it with the encrypted password available in the database
    
    if($oldpassword==$dbpass)
    {
       $status=true;
    }
    else
    {
       $status=false;
    }
    
    echo $status;
    ?>
    

    【讨论】:

      【解决方案2】:
      function Validate(data)
      

      这绝对不是他所要求的......你甚至读过他的问题吗?很可能不会。

      http://jssha.sourceforge.net/

      http://pajhome.org.uk/crypt/md5/sha512.html

      【讨论】:

      • 我是她呵呵呵呵...顺便说一句。很快就会回复..感谢您的指导。
      猜你喜欢
      • 1970-01-01
      • 2021-07-30
      • 1970-01-01
      • 2021-06-17
      • 2015-10-23
      • 2016-01-10
      • 2012-11-05
      • 2014-07-16
      • 1970-01-01
      相关资源
      最近更新 更多