Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Better way save password in mysql which can be decrypted also using php

I am currently using md5 function to encrypt my password and save to mysql db which can not be decrypted.

Now my user want that when they forgot password, they should get same (old) password instead of new password.

So my question is that what should i use to encrypt my password and store in mysql Database. And i can decrypt that password also.

i am running on php and mysql.

Thanks

Avinash

like image 821
Avinash Avatar asked Jan 25 '10 09:01

Avinash


1 Answers

Don't do that...

First, use something better than md5. Then create a way to "reset" the password, but never a way to actually retreive the password from the db...

That will make your app less secure, but maybe even worse; you and your users will have a problem if your data gets stolen! Someone is going to have a database with usernames and passwords of all your users!

like image 187
code-zoop Avatar answered Nov 06 '22 04:11

code-zoop