1

目前,我的许多密码都存储有 md5 和 sha1 的混合密码,但是我刚刚被介绍过加盐,并想知道最安全的密码的细分。

我确信一个简单的 md5() 可以很容易地被撤销,但是 md5(sha1(md5($var))); 呢?这个组合是否提供了更多的难度,或者更多不一定更好。

另外,正在做

$var = $var.'t00lup';
md5($var);

比上述更安全,假设 t00lup 是私钥?

有没有更好的方法来做到这一点,而不是只使用 md5 或只使用 sha1?

谢谢

4

5 回答 5

11

几件事:

  1. 只需使用 SHA256 - 不要费心重新散列。

  2. 不要只为每个帐户硬编码一个盐。为每个用户生成一个随机盐并将其放在数据库中的用户记录中。这样,如果有人为该盐生成彩虹表,至少他们将只能访问该一个用户帐户,而不是所有用户帐户。

于 2009-09-25T14:08:47.360 回答
5

更多不一定更好。只需使用 Sha256 即可。

$var = $var.'t00lup';
$hashedPass=hash('sha256', $var);

在此处阅读有关 hash()的更多信息。

于 2009-09-25T13:56:43.030 回答
4

Using a salt is absolutely required, because otherwise, an attacker can use existing precomputed tables to simply look up hashes for all short or dictionary passwords your users have used. You can try this yourself: take the MD5 of a very bad (short or dictionary) password and do a google search for the result - most likely you'll get a hit somewhere.

With a salt, existing tables become useless, and computing your own takes too long for all but the most resourceful and motivated attackers. Individual salts for each user are even better (otherwise an attacker who knows the salt can attack all your users at once).

Combining hashes could have a similar effect, but should not be used for that purpose (without a salt) because it's still possible for a precomputed table to exist for that combination.

However, the combination and repetition of hashes has a value of its own, by increasing the time it takes for an attacker to do a dictionary attack: applying MD5 ten thousand times still takes a fraction of a second and is feasible as part of the login process. But for a dictionary attack, taking 10,000 times as long is a problem.

This technique is known as key strengthening.

于 2009-09-25T14:37:17.877 回答
0

VBulletin 使用类似 md5(md5($password).$salt) 的东西。似乎还可以。

于 2009-09-25T13:59:56.207 回答
0

我认为做一些加盐可以提高安全性,因为它使字典攻击更加困难,而且即使密码很短,整个安全级别仍然可以。

最重要的事情实际上是散列算法和生成的散列的长度,所以你最好看看 sha256 或更好。

于 2009-09-25T14:02:00.960 回答