【问题标题】:Silex 2.0 : the algorithm "bcrypt" is not supportedSilex 2.0:不支持算法“bcrypt”
【发布时间】: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);

标签: php silex bcrypt


【解决方案1】:

尝试使用 bcrypt 编码器

$pass_encoder = new \Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder(13); 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-02
    • 2015-11-22
    • 2013-10-16
    • 2010-12-21
    • 2018-03-16
    • 2011-05-17
    • 2014-08-21
    • 1970-01-01
    相关资源
    最近更新 更多