title: Can I improve the security of MD5 hashed passwords by salting the existing MD5 hash and hash the result using Scrypt or PBKDF2 HMACSHA256?
body: <p>I have a database of legacy passwords that were salted and hashed using MD5.  I would like to update the system so that the data is more secure.</p>
  
  <p>The first option is to transition the users to a new hashing scheme (Salt + Scrypt or PBKDF2 HMACSHA256) when they login and deactivate old users after a certain period of time so they have to use the password recovery feature which would automatically update their hash.</p>
  
  <p>Another option that would allow me to instantly upgrade everyone would be to take the existing MD5 hashes, add a new random salt value to each, and then hash the result using the new hashing scheme (Salt + Scrypt or PBKDF2 HMACSHA256) and store that value to the database and delete the old value.</p>
  
  <p>Then when users login, I would have to apply the old, and then the new method.  I like the second option better since it allows me to remove all the old insecure hashes from the database sooner than later.</p>
  
  <p>Is it secure to salt and rehash the existing hashes?  Is MD5 so broken that I can run a script to de-hash the passwords and rehash them using the new scheme?</p>
  
  <p>Or maybe the best solution is to do a combination of both options?  This way I don't have to leave the existing MD5 hashes unsecured in the database and I can migrate users to the new system for a period of time?</p>