gpt4 book ai didi

php - Laravel Hash::check() 总是返回 false

转载 作者:IT王子 更新时间:2023-10-29 00:20:01 26 4
gpt4 key购买 nike

我有个人资料表格,用户可以编辑自己的个人资料。在这种形式下,我有当前密码。必须与从 sed 到数据库中匹配。

表格:

{{ Form::password('currPassword', array('id'=>'currPassword')) }}

我想在 Controller 中使用这个功能来检查数据库。

$data = User::find($id);
if( ! Hash::check( $data->password , Input::get('currPassword') ) )
{
return Redirect::to('/admin/profile')
->with('message', 'Current Password Error !')
->withInput();
}

散列 123456 密码进入数据库是可以的,将 123456 放入 currPassword 后必须返回 TRUE 但是总是返回 FALSE

最佳答案

您使用了错误的参数顺序。它是 Hash::check($input, $hash),而不是相反。

简短的修补程序示例:

[1] > $pw = 123456;
// 123456
[2] > $hashed = Hash::make($pw);
// '$2y$10$xSugoyKv765TY8DsERJ2/.mPIOwLNdM5Iw1n3x1XNVymBlHNG4cX6'
[3] > Hash::check($hashed, $pw);
// false
[4] > Hash::check($pw, $hashed);
// true

关于php - Laravel Hash::check() 总是返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21495502/

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