Question

Currently Many of my passwords are stored with a mixture of md5's and sha1's however I've just been introduced to salting, and wanted to know the breakdown of what might be the most secure.

I'm certin that a simple md5() can easily be revoked, however what about md5(sha1(md5($var))); Does this combo provide more difficulty, or is more not necessarily better.

Also, is doing

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

more secure than the above, assuming t00lup is a private key?

Is there a better way of doing this instead of just using md5 or just using sha1?

Thanks

Was it helpful?

Solution

More is not necessarily better. Just use Sha256 and be done with it.

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

Read more about hash() here.

OTHER TIPS

A couple things:

  1. Just use SHA256 - don't bother re-hashing.

  2. Don't just hardcode a single salt for every account. Generate a random salt for each user and put it on their user record in the database. That way if someone generates a rainbow table for that salt, at least they would only get access to that one user account rather than all of them.

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.

VBulletin uses something like md5(md5($password).$salt). Seem to be ok.

I think doing some salting improve security since it make dictionary attack more difficult and also even If the password is short the whole security level is still ok.

The most important things is really the hashing algorithm and the lenght of the resulting hash so you have better to look into sha256 or better.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top