Want to Convert a Website password Encryption from SHA1 to SHA256

Viewed 11929

just looking for some advise. I have a website with around 2500 users - small but growing. I built it with using SHA1 encryption on the passwords. I've since read the SHA1 is insecure and would like to change to say SHA256 with a Salt.

Does anyone have any advice on how to make a transition like this? Would be great if I could decrypt the passwords and just re-hash them but it doesn't appear doing able.

thx Adam

4 Answers

I have another suggestion to migrate your password hash from SHA1 to SHA256 immediately without waiting for user to visit the site again to rehash the password. The change will be one time password hash migration and change to your logon validation function.

Suppose your password hash are generated using the function: password + salt [Sha1]-> Hash-sha1

To migrate to Sha256, you may convert your password hash using the following algorithm:

Hash-sha1 + salt [Sha256]-> Hash-sha256 (The salt is used to increase the complexity of input.)

Depending on the acceptable value of your sha256 function, you can consider to encode the Hash-sha1 to base64 for printable ascii.

For your logon validation function, the password should be hashed using the following algorithm:

Password + salt [sha1] -> hash-sha1 + salt [sha 256] -> hash-sha256

The disadvantage is hashed twice (use some CPU time) but simplify the migration and better security.

Related