gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:45:33 26 4
gpt4 key购买 nike

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com