gpt4 book ai didi

jquery - 使用 Hash sha-512 在数据库中使用加密密码验证表单中的密码

转载 作者:行者123 更新时间:2023-12-01 04:21:55 25 4
gpt4 key购买 nike

使用哈希 SHA-512 在数据库中使用加密密码验证表单中的密码,我想做的是专门针对更改密码表单。

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

我想使用 jQuery 验证功能...但一直不知道如何通过在提交之前使用数据库对输入的密码进行加密来解决。

最佳答案

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;
?>

关于jquery - 使用 Hash sha-512 在数据库中使用加密密码验证表单中的密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9782510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com