加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2020-12-13 17:48:13 所属栏目:PHP教程 来源:网络整理
导读:echo crypt(‘test’,“$2a $07 $”);在 PHP版本5.4.16中生成一个长哈希,但它在5.6.4中生成“失败字符串”* 0. 读取crypt()上的PHP文档,我仍然不太清楚为什么,尽管Changelog提到* 1被返回而不是* 0,具体取决于具体情况. (http://php.net/manual/en/function.
echo crypt(‘test’,“$2a $07 $”);在 PHP版本5.4.16中生成一个长哈希,但它在5.6.4中生成“失败字符串”* 0.

读取crypt()上的PHP文档,我仍然不太清楚为什么,尽管Changelog提到* 1被返回而不是* 0,具体取决于具体情况. (http://php.net/manual/en/function.crypt.php)

在这种情况下返回* 0的原因是什么? PHP过去5.4是否已经停止了$2a $07 $形式的坏盐?

解决方法

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

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

Blowfish hashing with a salt as follows: “$2a$”,“$2x$” or “$2y$”,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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读