无需保存用户电子邮件即可恢复密码
嘿。 我正在开发一个网站,我想为丢失密码的用户提供一个密码恢复系统,但我不想保存用户电子邮件地址或任何私人数据。 我想过保存电子邮件地址的哈希值,但如果数据库遭到破坏,可以检查电子邮件地址是否已注册以及它属于哪个帐户。 你有什么想法吗?
hey there.
I'm developing a website and i want to have a password recovery system for the users who lost their password, but i don't want to save the user email address or any private data.
i thought of saving a hash of the email address but if the db is compromised one could check if an email address is registered and which account it belongs to.
do you have any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了防止数据库被破坏和提取哈希值,只需在兑现之前向所有电子邮件地址添加一些随机(但恒定的字符串)即可。例如添加“BLABLABLA”将“[email protected]”转换为“<哈希之前的 href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aac0c5cfeacfd2cbc7dac6cf84c9c5c7e8e6ebe8e6ebe8e6eb">[email protected]" 。它仍然不完美,但现在攻击者需要您的数据库、您的应用程序代码,对其进行逆向工程,并且知道这就是他首先需要做的事情(数据库中没有任何提示表明您的应用程序之前修改了电子邮件地址)散列)。
To protect against the DB being compromised and hashes extracted, just add some random (but constant string) to all email addresses before cashing. E.g. add "BLABLABLA" to turn "[email protected]" into "[email protected]" before hashing. It's still not perfect, but now an attacker needs your DB, your application code, reverse engineer it, and know that that's what he needs to do in the first place (there is no hint in the DB that your application modifies the email address before hashing).