Does any guidelines or best practices exist when it come to choose the length of the Salt data. Does it matter in the effort a hack has to put to match the dictionary (or rainbow) table with the hashed(passoword+salt) stored in DB.

In simple words, is there any ideal length of Salt data. Or choose a long Salt over short Salt. Why?


The length of the salt is not important once it has exceeded the minimum below which pre-calculation becomes cheap.

To quote Wikipedia:

Early Unix implementations limited passwords to 8 characters and used a 12-bit salt, which allowed for 4,096 possible salt values. This was an appropriate balance for 1970s computational and storage costs.

By my math, a 12-bit salt means someone could pre-compute rainbow tables for all 4096 salts; assuming a 7-8 character password, all it takes is 16 petabytes... certainly not out of the reach of many well-funded attackers today. Modern cryptographic algorithms tend toward 8- to 32-character salts in order to raise the bar (see table 2 here).

But I believe the length of the salt does not, for example, meaningfully impact the speed of each password calculation*. The choice of a good password algorithm will slow computations and lower the speed at which an attacker can mount a brute force attack; whether that algorithm is getting +8 characters of input is not going to make a significant difference compared to +16 characters or +32.

So as long as the salt isn't so small as to make pre-computation feasible, it's doing half of it's job. (The other half is to prevent Alice and Bob from having the same hash if they have the same password).

*That's my belief... but I'm not a mathematician or a crypto coder. Take that statement with a grain of, well, you know...

| improve this answer | |
  • 1
    Note that due to the birthday paradox, if you use random salts you'll start seeing duplicate salts when the number of users is around the square root of the number of possible salts. Duplicate salts are bad because al attacker can save effort by attacking groups of accounts at once. So, if you have a million users (that's 10^6 ~= 2^20), you should have salts long enough to have a million million different values (10^12 ~= 2^40). So ideally you want at least 40 bits of salt for that many users. – Gordon Davisson Jul 22 '17 at 21:15
  • frankly, the explanation is far more than what I could ask for. Gr8 and Tx. But I see an interesting math I would want to understand further and also like to mention that my understanding of cryp and hashing is very naive. So, could I get the math behind how 8 char password with 12 bit salt leads to 16 petabytes of dictionary (if i got it right) – samshers Jul 23 '17 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.