If a salt is just a random string of characters anyway, what is the purpose of changing the users salt each time they change their password?

closed as off-topic by Xiong Chiamiov, Serge Ballesta, schroeder Apr 5 '17 at 6:32

  • This question does not appear to be about Information security within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 8
  • 2
    Why not? It's easy and cheap to change salt, and it completely invalidates any potential attacker's brute force effort. – Lie Ryan Apr 4 '17 at 12:34
  • 2
    I'm voting to close this question as off-topic because it's a duplicate of crypto.stackexchange.com/questions/18963/… (but you can't close as duplicate of a question on another site). – Xiong Chiamiov Apr 4 '17 at 18:57
  • @XiongChiamiov I thought the reason you cant close a question as a cross site duplicate was that cross site duplicates are not automatically off topic. – Anders Apr 4 '17 at 19:48
  • Sure, but there's a lot of overlap between here and crypto.SE that makes a lot of questions (like that one) applicable in both places. But they really only need to be in one. – Xiong Chiamiov Apr 4 '17 at 20:52

From a coding perspective it's actually harder and less efficient to get the existing salt and re-use it than it is to just generate a new one. Using the old salt requires a round trip to the database or file, and requires extra complexity and code maintenance over simply creating an entirely new salt+username combo, which you have to have code for when the first password is set.

In other words, it's easier, faster, and safer to just use the same code you already have that creates a new salt, so why do anything else? From a security perspective, less code to maintain is more secure.


If the attacker has gotten hold of the old password and salt, she may be computing a rainbow table, dictionary or similar for that salt. If the salt doesn't change, that work would still be valuable even though the password is changed. Changing the salt forces the attacker to start over again.

Perhaps not a huge benefit, but on the other hand the cost of changing the salt is basically zero so there is no reason not to do it.


If a hacker has found a database of username + salt + hash, and wants to generally find passwords, they will try a huge number of potential passwords for various users; too many to store the calculated hashes.

If a hacker is after you and nobody you, they may be able to store all the calculated hashes, and if the password changes, they might already have the hash in their table and crack the password immediately. That is if the hacker can get at the same database again.

So on one hand changing the salt is only needed for users who are specifically targetted. On the other hand, I'd think that changing the salt should be easy, so there's no reason not to change it.

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