This only apply to systems that uses one-way hashing method to store passwords, and compares hashes at authentication.
If there is a frequent such upgrade required of your system, I would do the following.
As Taymon has pointed out, hashing is one way and there is no way you can retrieve the original plain text from the hash.
In my database table storing the user information and password, I would include a Hashing Level integer field. This indicates which hashing method the user is using.
When the system is added with a new hashing method, the highest Hashing Level will be incremented.
Let's say if I have 2 hashing methods already
1 MD5
2 SHA1
3 SHA256
If I add in a new hashing method SHA512
, it'd become
4 SHA512
Every time the user signs in, the system will check if the user's password is the same as the one in the database, using the identified Hashing Level. There are several cases here:
- If the password hashes match, but the Hashing Level of the user is not the highest Hashing Level the system offers, then hash the input password of the user i.e. the plain text using the highest level of hashing method and set the Hashing Level of the User to the highest Hashing Level. The user is then authenticated.
- If the password hashes match and the Hashing Level of the user is the highest Hashing Level, then the user is authenticated.
- If the password hashes do not match at all, then the user is denied.
This means that whenever you upgrade the hashing level of the system, the user's password is only upgraded to the highest level at their next authentication.