作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在 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!";
}
?>
或者在我的例子中是这样的:
$stored_password=fetch_password($user);
if (crypt($_REQUEST['password'],$stored_password)===$stored_password) {
// ok
}
因此,当我看到盐存储在散列密码中并且您使用该散列密码作为盐时,我认为 Crypt + Salt 对于输出的暴力破解(设法窃取散列密码的黑客)并不更安全).它更安全吗?
对于字典攻击,我能理解它的威力,但对于对散列密码的暴力攻击,我看不到它的优势。
最佳答案
在散列之前将盐应用于字符串(示例中的密码)时,散列现在变成了另一个散列,而不是没有盐。没有盐,你可以只使用一个预先存在的字典——现在你需要为盐创建一个字典。如果您使用用户特定的盐,则每个用户在使用蛮力时都需要拥有自己的字典。这变得更加耗时。
MD5 是一个错误的算法,因为它的 collision vulnerabilities .
关于php - Crypt 和 Salt 如何比 MD5 更安全地抵御暴力攻击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8646455/
我是一名优秀的程序员,十分优秀!