Search code examples
phpsqlpassword-encryptionpassword-recovery

Decryption of password encrypted using PASSWORD() function of mysql


I am usingPASSWORD()function of SQL for encrypting passwords . Now i am searching for a way to get the password if someone forget his/her password.

$user = "select * from users where email='$email' and password='PASSWORD($pass)'";

Thanks


Solution

  • You should never store your passwords in a way that they can be decrypted. Instead just generate a new password.

    Something like:

    UPDATE users SET `password` = 'PASSWORD(someSuper.Safe123Password!)' WHERE `id` = USERID