I have a PHP application that has a somewhat decent user base. Now, unfortunately, he has been using sha1 ($ password. $ Salt) all these years, and I really want this to be in favor of bcrypt. I found some good ways to get a Blowfish hash, but I'm still not sure what I should use for the conversion. Here are my options:
Option 1
Every time a user logs in, I check to see if the hash starts at $ 2. If not, I assume it is sha1, enter the password entered by the user, get the bcrypt hash for it and replace the old hash in the database.
Option 2
I will replace my auth class to do this:
$hash = password_hash("rasmuslerdorf", sha1($password . $salt));
Thus, the conversion is faster.
But honestly, I donโt really like any of the options. Both suggest that I still keep the deprecated check in the codebase I want to get rid of.
Any suggestions which of the above two are better in terms of coding standards? Or does anyone have a better solution?
source share