我在PHP.net上看到MD5没用,他们建议使用crypt + salt.
所以,我去了他们的功能描述并阅读
<?php
$password = crypt('mypassword'); // let the salt be automatically generated
/* You should pass the entire results of crypt() as the salt for comparing a
password, to avoid problems when different hashing algorithms are used. (As
it says above, standard DES-based password hashing uses a 2-character salt,
but MD5-based hashing uses 12.) */
if (crypt($user_input, $password) == $password) {
echo "Password verified!";
}
?>
Run Code Online (Sandbox Code Playgroud)
或者在我的情况下:
$stored_password=fetch_password($user);
if (crypt($_REQUEST['password'],$stored_password)===$stored_password) {
// ok
}
Run Code Online (Sandbox Code Playgroud)
因此,当我看到salt存储在散列密码中并且您使用散列密码作为salt时,我认为Crypt + Salt对于输出上的暴力(黑客成功窃取哈希密码)并不安全.它更安全吗?
对于字典攻击,我可以理解它的强大功能,但是对于哈希密码的暴力攻击,我没有看到它的优势.
具有哈希值的加密比 MD5 更昂贵。攻击者需要更多的计算时间,因此更安全。
对于密码和 MD5,攻击者可以使用 MD5 的预计算表 PLUS 具有 MD5 速度非常快的优点。
对于密码和 salted crypt,预先计算的表是无用的,PLUS crypt 需要比 MD5 更多的马力
有一些专门设计的算法(google bcrypt),故意提高计算成本以进一步实现这一点。
| 归档时间: |
|
| 查看次数: |
4293 次 |
| 最近记录: |