Search code examples
databaseencryptionphpmyadminmd5database-migration

phpmyadmin md5 decryption issue after importing database


I have a database on a cpanel server, which contains a user field called 'password'. When I look at the field through phpmyadmin, all the passwords appear as md5 encrypted.

So for example, a password thats '12345' would be encrypted and appearing in the database as "e10adc3949ba59abbe56e057f20f883e". Now, on the original server, thats ok, because even if the password is encrypted in database, when I enter the password on the related website as '12345' it recognizes it and gives access.

The problem is when I export and import the database. After importing the same database into another server, naturally the password values are still encrypted in the database. But, when I try logging in into the related website, the decrypted password, tht is, '12345' does not work anymore. I have to enter the password as "e10adc3949ba59abbe56e057f20f883e" and only then I can login. So I'm guessing the problem is that the data in the password column is not getting decrypted after importing to another database, hence when I enter '12345' instead of the extended md5 value, it does not match and gives me a wrong password error.

So can anyone help me solve this issue? I am supposed to migrate this website on another server, and its a school system, and currently none of my users have access because of this issue.

Thanks.


Solution

  • md5 is not encryption, it's a one-way hash. You cannot find the original value from a hash.

    On the second server, if the e10adc3949ba59abbe56e057f20f883e password works, the only reason I see, is that the application is not comparing the hash of the input value it received from the user, it's comparing the input value itself.