更好的方法将密码保存在mysql中,也可以使用php解密 [英] Better way save password in mysql which can be decrypted also using php

查看:19
本文介绍了更好的方法将密码保存在mysql中,也可以使用php解密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用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!

这篇关于更好的方法将密码保存在mysql中,也可以使用php解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆