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 协议》,转载必须注明作者和本文链接
推荐文章: