Function to reverse md5()?

If I had encrypted (or hashed) a string using md5(), is there a function that I can use to decrypt to get back the original string?

Nope. MD5 is one way.

Try using the mcrypt library if you want two way encryption.

No sorry, impossible, which is why it is used to store password fields.

You can compare against it, ie. if(md5($password)) == $password_from_db) but I am pretty sure it cannot be deciphered.


Edit: Beaten :lol:

If that’s for user system “lost password” feature, you can generate a new password and send it to user.

Either that, or flag an option in the database that the next time the user logs on, they are presented with a screen to choose a new password.

Any system that can return my password to me in plain text after I have entered it, will be the last time I use that system.


Unless you get hold of the Chinese researcher who just broke SHA1, no.

Yep. saw it being slashdotted. But can we trust a chinese media is a different story altogether.

You can’t “break” md5. The algorithm throws information away, so there is no way you can reverse the process.

“To break” md5 (or another hash function) means “to invert” it, eg. given a hash value H, quickly find a string S so that H = md5(S). S doesn’t have to be orginal source string, but this usually doesn’t matter. For md5, such an algorithm has been indeed found.