laravel Hash::check 始终返回false?
You’re using the wrong argument order. It’s Hash::check($input, $hash)
, not the other way around.
Short tinker example:
[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
发现测试这段代码 可以正常返回ture,但是把加密后的password存放到数据库后,再拿出来,就发现总是 false了,后来才发现,Mysql的数据库字段长度设置的是20,加密后的字符串长度超过20了,mysql居然没有报错,直接自动截取20位后保存。这就是总是返回false的原因了。
想问问 mysql 怎么可以调整设置呢?
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: