Laravel 5.2 Bcrypt 损坏因此 Auth 损坏

Laravel 5.2 Bcrypt broken therefore Auth broken

所以我不知道发生了什么,但这里有一些乐趣给你。如果我这样做

return bcrypt('hello');
exit();

和 运行 这是我得到的 3 倍:

第 1 名:y$T11IfKkHIAIXi0SRhjMXKeSQQtze8zBVZnWdlRXfsSdcCXKIq/n7W

第二名:y$DpKVtgbF4OVa3jm.wdG5..jb9AvXsuo2EfqnjuzmsEVCmcOVr5nKq

第 3 名:y[=14=].ziFneJu0wrS2b3rHA6kucnGBkS2MRtgfp0gtEb/7ZOCV8dG3Mmq

我被难住了。在 laravel 5.1 工作 - 不知道是不是我的错。对不起。还有谁有相同的问题吗?有解决办法吗?

如果我得到答案并不重要,5.2 是 shite 不是很好,我要回到 laravel 5.1 因为 A) 它更稳定B) 它是在 Taylor Otwell 让 Gibbons 参与该项目之前开发的。尽管我会问,以防万一有人遇到这个问题并为其他偷窥者修复它。

您想使用 Hash::check 函数

Hash::check('hello', 'y$T11IfKkHIAIXi0SRhjMXKeSQQtze8zBVZnWdlRXfsSdcCXKIq/n7W');

=> true

Hash::check('not-hello', 'y$T11IfKkHIAIXi0SRhjMXKeSQQtze8zBVZnWdlRXfsSdcCXKIq/n7W');

=> false

Hash::check('hello', 'y$DpKVtgbF4OVa3jm.wdG5..jb9AvXsuo2EfqnjuzmsEVCmcOVr5nKq');

=> true

Hash::check('hello', 'y[=10=].ziFneJu0wrS2b3rHA6kucnGBkS2MRtgfp0gtEb/7ZOCV8dG3Mmq');

=> true

Hash::check('hello', 'y[=10=].ziFneJu0wrS2b3rHA6kucnGFkS2MRtgfp0gtEb/7ZOCV8dG3Mmq');

=> false

要解释其工作原理,您可能需要查看维基百科 page

For example, the shadow password record a$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy specifies a cost parameter of 10, indicating 210 key expansion rounds. The salt is N9qo8uLOickgx2ZMRZoMye and the resulting hash is IjZAgcfl7p92ldGxad68LJZdL17lhWy. Per standard practice, the user's password itself is not stored.

另求多读Do any security experts recommend bcrypt for password storage?

阅读更多 Storing User Passwords Securely: hashing, salting, and Bcrypt