我仍在为我的网站使用md5哈希,我需要升级,但我不知道如何... 这是我现在使用的代码
$salt1 = "mysite";
$salt1 = md5($salt1);
$salt2 = "passed";
$salt2 = md5($salt2);
$salt3 = "php";
$salt3 = md5($salt3);
$password1 = $salt1.$password1.$salt3;
答案 0 :(得分:3)
希望你升级到bcrypt,现在是the standard。 (PHP 5> = 5.5.0)
最简单的方法是将密码存储在两列中。当有人连接并且他们没有bcrypt哈希密码时,请输入他们输入的有效密码,用bcrypt哈希,然后将其存储在新列中。该用户现已转换,您可以删除旧的MD5。
几个月后,禁用那些长时间未使用该网站的用户,并让他们重置密码以获取访问权限。这允许逐步过渡,用户影响最小。
对于尚未升级到PHP 5.5的用户,还有密码兼容包
答案 1 :(得分:1)
<?php
/**
* In this case, we want to increase the default cost for BCRYPT to 12.
* Note that we also switched to BCRYPT, which will always be 60 characters.
*/
$options = [
'cost' => 12,
];
echo password_hash("rasmuslerdorf", PASSWORD_BCRYPT, $options)."\n";
?>
这是来自php手册,它将是你需要进入的方向。我建议进一步阅读PHP内置的bcrypt功能,以获得更深刻的理解。