![]() |
Best way to use salts?
I've been wondering this for a while.
** - Which way would be best? PHP Code:
|
1. Not necessarily. Salts have to turn a string no matter how small into a string (well, base-16 number in md5's and sha1's case) of a given size. The fewer characters the string is the more values overlap, but the larger the string is the more patterns it reveals that can allow it to be reverse-engineered.Keep in mind that these hashing functions are all advanced mathematical algorithms.
2. In a closed source app, there is no best way. Just attach something anywhere on the string and it will throw the entire hash out of whack. |
Alright, thanks.
|
In the case of a user auth class you could randomly generate a salt for each user at registration and store it in their database record, so the salt is different for each user. Assuming your database is secure it will now be a massive challenge for anyone to work out your encyption technique....
Just an idea, any thoughts? |
Quote:
After that I would use a randomly assigned (shuffled) assortment of [a-z0-9(symbols)] to use in conjunction with a hash to provide a secure string which can be reproduced (with the correct PW) and doesn't contain the PW. (So if they do crack the hash they would have to crack several random number generations, then pretty much guess at the original PW). The trouble is then what comes with really secure or insecure PW's? Could/Should they be strengthened or weakened before the assignment, do they alter the theoretical complexity of the hash? *EDIT* Crap! There would be no way to validate a random string generated from the numerical value of the entered PW, it would be the seed for a PRNG. Therefore ever changing! Scrap that.. |
Yeah you really need to be able to retive the value of the salt for each logon which is why I suggested storing it in database.
I would have thought something like sha1(md5($password)), $salt); would be secure enough wouldn't it? |
Quote:
|
Fair point ^^ I reasoned that in most cases the MD5 output would be a lot longer and therefore more complex then the input string, for example a 6 char password vs an MD5 string.
|
Quote:
Rainbow tables can us used against either one easily, but even a simple salt makes those useless. |
Mostly I use this technique:
PHP Code:
|
Quote:
|
Why not? Could you explain that?
|
Packing it merely scrambles the value in a known (and reversible) way before hashing it. This does not add any more security than adding a simple value to the hash because the values can't be reverse engineered either way.
|
Quote:
|
Quote:
How is there a bigger risk if collision with a simple salt? |
Quote:
Using the following code: PHP Code:
Quote:
Quote:
About the risk with a simple salt: That's not what I meant :) I mean, there is always a risk that there occurs a collision. |
Since MD5 doesn't leave a footprint when you salt, any salt will make reverse engineering measures pointless. The only way they can get past a salt it to guess exactly where it was in the string and its exact value. Which is practically impossible when you don't know the original string.
It in high theory is harder to guess a salt that long and complex, but for all practical purposes it is pointless. Edit: a quick mathematical layout A normal salt with only letters, numbers and punctuation marks that is twelve characters long has approximately 12^51 (~1.1x10^55) possible combination. While yours would have much higher number like 45^70 (~ 5.3x10^115). At one million guesses per second, it would take a computer 3.5x10^41 years to guess the plain salt. Yours would take 1.7x10^102. Neither of these account for the fact that the location is unknown (meaning each possible location is another one of these) and you cant verify your finding is correct without the original password to compare it against. It would take far less time to brute force the password itself opposed to reversing the hash. |
True, totally true. :)
|
| All times are GMT. The time now is 09:19 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0