Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I incorporate the salt in my password hash?

How much stronger would

return sha1($salt.sha1($passwd));

be compared to just:

return sha1($salt.$passwd);

$salt is a per-user string of length 12 consisting of strong random ASCII.

like image 655
Tomek Wojtek Avatar asked Feb 28 '23 19:02

Tomek Wojtek


1 Answers

It's exactly twice as strong, because the attacker needs to perform twice as many SHA1 calculations for a brute force attack.

Of course, that is still not exactly impressive. On the other hand, doing the SHA1 5000 times in a loop is practical for authorization, but makes attacks take 5000 times longer - this technique is known as key strengthening. It is, however, really just a poor man's substitute for the adaptible-cost hash algorithms that Jacco mentions.

like image 108
Michael Borgwardt Avatar answered Mar 16 '23 22:03

Michael Borgwardt