一个快速而肮脏的实验。PHP crypt问题
我把这段代码放到一个.php
文件中,并从我的虚拟主机上加载它。
结果是“It works!”但为什么?它应该失败了吗?我是从这里以下示例#1:http://php.net/manual/en/function.crypt.php
<?php
$pass1 = "thetimeshallwhintercows";
$salt = "temperpedic";
$crypt_pass = crypt($pass1, $salt);
if($crypt_pass == crypt("thetimeshallwhintercowz", $crypt_pass))
{
print("It works!<br/>");
print($crypt_pass );
print("<br/>");
print(crypt("thetimeshallwhintercowz", $crypt_pass));
}
else
{
print("try again....");
}
?>
示例#1 [上页状态(http://php.net/manual/en/function.crypt。 PHP)(作为代码中的注释)'//让盐自动生成。如果您要从同一页面使用(添加)'$ user_input =“mypassword”;'然后将其修改为'$ user_input =“mypassword2”;'您会看到它实际上将按预期工作。 –
[重新排列的答案](http://stackoverflow.com/a/20625155/1415724)很有意义,并且“正确的金钱”。你的第一个8个字符不应该是一样的。 –