3 ms·
I don't know how I should feel about this secure method of generating a salt that is used for almost everything as it seems: // random salt $sSalt = '<'.'?
by TimWolla 12y ago
I don't know how I should feel about this secure method of generating a salt that is used for almost everything as it seems:
// random salt
$sSalt = '<'.'?php //'
.md5(microtime(true).rand(1000, 5000))
.md5(microtime(true).rand(5000, 9999))
.md5(microtime(true).rand(1000, 5000));
@file_put_contents(APP_DATA_FOLDER_PATH.'SALT.php', $sSalt);
It looks like they just threw some cryptographic hash functions at things and hope it works out.
- deleted 12y ago[deleted]
- jnbiche 12y agoI don't really know PHP, but what's the problem? A salt doesn't have to be perfectly random. It just should be unlike any other salt in use. This looks like it would meet that requirement. Edit: Since this is HN, I feel obliged to point out that there is a small vulnerability introduced by using a non-CSPRNG here. If an attacker is already surveiling you, and is able to perfectly deduce the state of your PRNG before you generate your salt, and the attacker plans to steal your db at some point in the future, he can get a head start in generating rainbow tables against your database. But the main value of a salt is in being globally unique, which this is.
- chacham15 12y ago>he can get a head start in generating rainbow tables against your database. While it is true that he can get a head start, a head start is quite useless because the work necessary to reverse one hash is independent of the work necessary to reverse a different hash. That means that you still have to brute force each password individually.
- mintplant 12y agoIt's not my project, but I'm sure a pull request would be appreciated. https://github.com/RainLoop/rainloop-webmail https://github.com/RainLoop/rainloop-webmail
- chacham15 12y agoThe main purpose of a salt is to defeat a rainbow table. I.e. using a precomputed table of all possibilities to lookup more than one password at once. If the salt is different for each password, that guarantees that the work used to solve one password cannot be used for the other. Cryptographic randomness is not necessary, just uniqueness.