Laravel Hash::check() always return false(Laravel Hash::check() 总是返回 false)
问题描述
我有个人资料表格供用户编辑自己的个人资料.在这种形式中,我有当前密码.必须从 seved 匹配到数据库中.
I have profile form for user can edit own profiles. in this form I have current password. that must be match from seved into database.
表格:
{{ Form::password('currPassword', array('id'=>'currPassword')) }}
我想在 Controller 中有这个功能来检查数据库.
i want to have this function in Controller to check this with database.
$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.
hashed 123456 password into database is ok and after putting 123456 in currPassword that must be return TRUE but that return FALSE always.
推荐答案
你使用了错误的参数顺序.它是 Hash::check($input, $hash),而不是相反.
You're using the wrong argument order. It's Hash::check($input, $hash), not the other way around.
简短的修补程序示例:
[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
这篇关于Laravel Hash::check() 总是返回 false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Laravel Hash::check() 总是返回 false
基础教程推荐
- 如何替换eregi() 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
