更好的方法将密码保存在mysql中,也可以使用php解密可以使用、存在、密码、方法

2023-09-06 23:22:31 作者:枪抢稳扎婊子心

我目前正在使用md5函数加密我的密码并保存到无法解密的mysql数据库中.

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.

所以我的问题是我应该使用什么来加密我的密码并存储在 mysql 数据库中.我也可以解密那个密码.

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.

我在 php 和 mysql 上运行.

i am running on php and mysql.

谢谢

阿维纳什

推荐答案

不要那样做...

首先,使用比 md5 更好的东西.然后创建一种重置"密码的方法,但绝不是从数据库中实际检索密码的方法......

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!