Question

Now i am using SHA256 of password is saving. But in future, SHA256 may subject to collision. That time i am unable to change password hashing method. So anyone can suggest proper method for saving plain text backup that is in secure way

Était-ce utile?

La solution

I assume that your question is about how to switch to a better hashing algorithm, when the original password is not known anymore.

To begin with, today it is recommended to use a slow key-derivation function like BCrypt or PBKDF2 to store passwords (not a fast SHA*). If there is no real need to know the original password, you shouldn't store it plaintext. Collisions are not a problem with password hashes.

If you want to switch to a better hashing algorithm, you have two options, either you wait until the user logs in the next time (then you know the original password), or you can double hash the existing hash. The usual workflow will look like this:

  1. First try to verify the entered password with the new algorithm. New passwords and already converted passwords will not take longer for verification then.
  2. If it does not match, compare it with the old hash algorithm.
  3. Should the old hash value match, then you can calculate and store the new hash, since you know the password then.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top