If you're looking to move the project forward then you might be best doing something like checking the password against the current rijndael encrypted - if it matches re-encrypt it as bcrypt and save the new password - maybe with a field of 'has_migrated' on the user set so you can skip the check next time?
Migrate to Laravel with old hashed user passwords.
I am trying to migrate an old PHP project to Laravel where user passwords were stored using MCRYPT_RIJNDAEL_128 cipher and a 43 symbols key (which is not supported in php 5.6 that is required for the latest Laravel version). What is the best way to keep existing user passwords while migrating to Laravel?
There is already some sound advice here (and cheers for the actual code-snippet, @MikeHopley ), but I'd like to underscore a couple of crucial points that are not Laravel-specific (even if that means they are slightly off-topic).
1.) At no time should the old hash be stored in a separate column (even if the plan is to destroy it within some reasonable time-frame); doing so introduces significant risk without justification. This is exactly how Ashley Madison passwords were cracked ( http://cynosureprime.blogspot.com/2015/09/how-we-cracked-millions-of-ashley.html ):
The recommended approach is to store the algorithm along with the hash e.g. MD5:hash:salt or bcrypt12:hash:salt. This allows you to easily identify what algorithm to use on a per-user basis. When you deem an encryption strategy obsolete you can still protect your existing users by wrapping their existing hash in a new algorithm; in this case that would be bcrypt-ing the existing md5 hashes and storing something like md52bcrypt:hash:salt.
2.) In an ideal implementation (and I haven't done the research required to know if Laravel qualifies), there is no need to have a separate has_migrated field, or similar. This is for two reasons: a) this type of migration should be an ongoing process that happens every time that significant risk against a given hashing algorithm emerges publicly, thereby rendering such a column illogical, and b) it is redundant, because in an ideal implementation, the algorithms that have been used to compute a hash are embedded in the stored value.
3.) There is no need to send out an email blast at any point, because in an ideal implementation, every user's password is wrapped in the newest/strongest hashing algorithm, even if there are several hashing "layers" for any given user's password. One might visualize this strategy with the following pseudo-code: scrypt(bcrypt(sha1(md5('theuserspassword')))).
One of the more comprehensive road-maps that I've seen regarding this subject may be found at:
@uther_bendragon/sustainable-password-hashing-8c6bd5de3844" target="_blank">https://medium.com/@uther_bendragon/sustainable-password-hashing-8c6bd5de3844
Stay safe out there! ;)
Please or to participate in this conversation.