PHP crypt() returns *0 版本 5.6.4 中的失败字符串,但不是 5.4,

PHP crypt() returns *0 failure string in version 5.6.4, but not 5.4,

echo crypt('test', "a$"); 在 PHP 版本 5.4.16 中生成长散列,但在 5.6.4.

中生成 "failure string" *0

阅读有关 crypt() 的 PHP 文档,我仍然不太清楚为什么,尽管更新日志提到根据情况返回 *1 而不是 *0 . (http://php.net/manual/en/function.crypt.php)

在这种情况下返回 *0 的原因是什么? PHP 5.4 之后是否不再容忍 a$ 形式的坏盐?

Blowfish 定义说您必须在第三个 $ 之后定义一个字符串。

<?php
echo crypt('test',  "a$mystring");
?>

Blowfish hashing with a salt as follows: "a$", "x$" or "y$", a two digit cost parameter, "$", and 22 characters from the alphabet "./0-9A-Za-z"

如果您未定义该字符串,则会出现错误 *0

5.6.5 When the failure string "*0" is given as the salt, "*1" will now be returned for consistency with other crypt implementations. Prior to this version, PHP 5.6 would incorrectly return a DES hash.