0
我有一个使用hash_pbkdf2哈希密码的现有表。对于用户注册,它的成功插入到MySQLlaravel php pbkdf2登录验证
$string = mcrypt_create_iv(24, MCRYPT_DEV_URANDOM);
$salt = strtoupper(bin2hex($string));
$hash = hash_pbkdf2("sha1", $data['password'], $string, 1000, 24, true);
$hash = strtoupper(bin2hex($hash));
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'hashedpassword' => $hash,
'salt' => $salt,
]);
我有麻烦登录和使用它。这里是我的代码
$found_salt = DB::table('users')->where('email', '[email protected]')->first();
$salt = $found_salt->salt;
echo "Salt : ".$salt."<br>";
$hash = hash_pbkdf2("sha1", "password", $salt, 1000, 24, true);
$hash = strtoupper(bin2hex($hash));
$userlogin = [
'email' => "[email protected]",
'hashedpassword' => $hash
];
echo "Hash : ".$hash."<br>";
if(Auth::attempt($userlogin)) {
echo "success";
} else {
echo "not success";
}
盐值相同,但散列值不匹配。希望有人能帮助。谢谢。