php - Crypt 和 Salt 如何比 MD5 更安全地抵御暴力攻击?

标签 php md5 crypt

我在 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/

相关文章:

php - 如何确定文件是否仍在通过 ftp 传输

php - 使用 Tinker 和 Laravel 进行编码

c++ - Crypto++ 多字节/unicode 问题

php - 在 MySQL 中为 datetime 添加秒数

php - PHP结束标记:=?>

python - 在 BeautifulSoup 结果上使用 md5

c# - Java 与 C# 中的 UTF-16 编码

c# - C#和golang的MD5不一致

php blowfish 哈希与 crypt() : the CLI result differs from webserver's one

javascript - 有人见过 Javascript 中的 crypt(3) 实现吗?