【发布时间】:2016-05-30 09:14:23
【问题描述】:
我有一个 Silex 项目,我正在从 Silex 1.3 升级到 Silex 2.0。 该项目在 1.3 上运行良好,但我遇到了 bcryt 加密错误,因为它似乎随着 Silex 2.0 更改了默认编码。
Silex 用这两行抛出错误 The algorithm "bcrypt" is not supported :
$pass_encoder = new MessageDigestPasswordEncoder('bcrypt', true, 13);
$pass = $pass_encoder->encodePassword($si_pass, $si_salt);
我在 PHP 5.5.28 中使用 XAMPP,启用了 mcrypt 支持并启用了 mcrypt_filter 支持。
感谢您的帮助!
【问题讨论】:
-
尝试使用
\Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder -
在你的文件顶部添加
var_dump( hash_algos() );看看你的数组中是否有 bcrypt。 -
use 语句没有帮助。在
hash_algos()数组中有很多(md5、sha、ripemd、tiger、hava ...)但我找不到任何 bcrypt ! -
等等,如果我使用这个
$pass_encoder = new BCryptPasswordEncoder('bcrypt', true, 13);,它似乎可以工作,它会抛出这个错误Cost must be in the range of 4-31.。这个函数我不熟悉,参数是什么? -
$pass_encoder = new BCryptPasswordEncoder(13);