gpt4 book ai didi

symfony - 用户密码字段的最大长度为 "algorithm: auto"?

转载 作者:行者123 更新时间:2023-12-02 19:07:12 24 4
gpt4 key购买 nike

Symfony 4.3 弃用了 bcrypt 算法,请参阅 UPGRADE-4.3.md :

Configuring encoders using argon2i or bcrypt as algorithm has been deprecated, use auto instead.

所以我将 security.yaml 更改为:

encoders:
App\Entity\User:
algorithm: auto

问题是,改成auto后,哈希后的字符串变长了:

'INSERT INTO users (..., password, ...) VALUES (...)' with params [..., "$argon2id$v=19$m=65536,t=6,p=1$d2RhZjVuaWJsSnE0TW5haA$ycOn7EHjPOoBTSa6SHDOBWL2AvwfPNjAstlSTEMmPpU", ...]:

SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'password' at row 1

该字符串的长度为 97 个字符,而我的密码列为 64。我没有找到任何有关“auto”属性的最大可能长度的文档,是 97 吗?或者可以更多?

最佳答案

正如 @Cerad 在评论中所说,auto 模式可能总是会生成 password_hash() 内置 PHP 函数支持的密码(取决于平台)。
因此,您可以放心地依赖 the password_hash() documentation 给出的提示。 :

PASSWORD_DEFAULT - [...] Note that this constant is designed to change over time as new and stronger algorithms are added to PHP. For that reason, the length of the result from using this identifier can change over time. Therefore, it is recommended to store the result in a database column that can expand beyond 60 characters (255 characters would be a good choice).

关于symfony - 用户密码字段的最大长度为 "algorithm: auto"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56394016/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com