PHP-我应该加密电子邮件地址吗? [英] php - Should I encrypt email addresses?

查看:82
本文介绍了PHP-我应该加密电子邮件地址吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户注册时,我应该将其电子邮件原样存储在db中还是对其进行哈希处理. 我希望以后能够解密它,所以我应该使用md5吗?

When users register, should I store their email in the db as is or hash it. I want to be able to decrypt it later, so should I use md5?

谢谢!

推荐答案

否,md5()-是一个哈希函数.您无法解密其值.通常,它用于不需要解密的密码.相反,您比较散列,例如:

No, md5() - is one-way hash function. You can't decrypt its value. Usually it used for passwords which don't need to be decrypted. Instead you compare hashes like:

$salt = "adding some secret to increasse security";
if (md5($user_password . $salt) == $user_password_hash_from_db) {
    ## password is ok
}

如果您希望能够解密您的值,请使用 crypt PHP功能代替.但这可能需要安装其他模块.

If you want to be able to decrypt your value, then use crypt php function instead. But it may require additional modules to be installed.

无论如何,我看不到任何实际的原因来加密电子邮件.

Any way I don't see any practical reason to crypt email.

这篇关于PHP-我应该加密电子邮件地址吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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