Information Security Stack Exchange is a question and answer site for information security professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Salts are supposed to be unique and randomly generated for each user when storing passwords. Is there a reason why we can't generate these salts with a cryptographic hash function using the username as the input?

It appears to me that these hashes would give the properties we desire, and we wouldn't have to use additional storage space for the salts.

share|improve this question
After more searching, I found a reason why you shouldn't use a hash of the username as a salt: The user name does not change when the user changes their password. An attacker seeing the old hashed password and the new hashed password may attack both at a cost less than twice the cost of attacking one. – gbooooooo Jul 24 '13 at 17:30
Yes. Each new hash should have a new salt, otherwise by cracking one hash and saving all previous attempts, you now have a rainbow table to start with for all future password changes by that user. – KeithS Jul 24 '13 at 17:40
@gbooooooo Congratulations, the results of your own research are absolutely correct. (Now, all that's left to do is to post your comment as an answer to your own question and accept it.) – e-sushi Jul 24 '13 at 18:20
up vote 3 down vote accepted

Good salts are unique over the whole range of space-time.

A user does not change his name when he changes his password: that's a failure of uniqueness over time. (Similar case: an old user account is closed, a new user is registered and reuses the same name.)

A user has the same name on several distinct servers, which may employ the same hashing strategy: that's a failure of uniqueness over space. (Think, in particular, of all these users called "Administrator".)

User names are thus rather sloppy as salts. They are much better than no salt at all, but it is highly recommended to use proper random salts instead. 16 bytes (or more) from a cryptographically strong PRNG will give you much better uniqueness.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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