简体   繁体   English

不同版本的PHP不同的crypt()结果

[英]Different versions of PHP different results of crypt ()

Code: 码:

echo $a = 'stackoverflow';
echo '<br>';
echo $b = '$2a$10$bf57caf7e1fa23e4b975ab';
echo '<br>CRYPT:<br>';
echo crypt($a, $b);

Results: 结果:

PHP 5.2.5 PHP 5.2.5

stackoverflow
$2a$10$bf57caf7e1fa23e4b975ab
CRYPT:
$2.LaeiP21fsQ

PHP 5.4.4 PHP 5.4.4

stackoverflow
$2a$10$bf57caf7e1fa23e4b975ab
CRYPT:
$2a$10$bf57caf7e1fa23e4b975aOhXjTtYrqOYLfHsxdOxGRhF03.LtKewW 

I want to move the script to a new server with PHP 5.4.4 I would like to get the same effect as the 5.2.5 hashes, otherwise I will lose some data 我想用PHP 5.4.4将脚本移动到新的服务器我希望得到与5.2.5哈希相同的效果,否则我会丢失一些数据

If I use salt with ending $ - the result is the same 如果我使用salt结束$ - 结果是一样的

I read this: 我看了这个:

As of PHP 5.3.0, PHP contains its own implementation and will use that if the system lacks of support for one or more of the algorithms. 从PHP 5.3.0开始,PHP包含自己的实现,如果系统缺少对一个或多个算法的支持,将使用它。

But the algorithm should not be different. 但算法不应该有所不同。

Please help. 请帮忙。

Prior to PHP 5.3.0, Blowfish was only available if your system's C library provided it (and almost no one's did). 在PHP 5.3.0之前,Blowfish仅在您的系统的C库提供它时才可用(并且几乎没有人提供)。 Passing a Blowfish salt in systems that don't have a Blowfish implementation results in a crapshoot of algorithm selection - usually, a DES hash. 在没有Blowfish实现的系统中传递Blowfish盐会导致算法选择的错误 - 通常是DES哈希。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM