在 Java 中保证用户密码安全?
我已经到了需要选择一种方法来安全地将用户密码保存在数据库中并能够在用户登录网站时检查密码是否匹配的时候。
我目前使用的是 Spring 2.5,但正在慢慢升级到 Spring 3。您对我如何保证密码安全有什么建议?我知道这个问题已经在这里和那里以类似的形式得到了回答,但我希望看到一些关于如何做到这一点的准确的、最新的答案,这也可以防止当今的密码黑客攻击技术。
用盐对密码进行哈希处理的最合适方法是什么?我的意思是哪种算法更好(如果有的话)?我应该使用 bcrypt 来代替吗?jBCrypt 是一个很好的库吗?有没有更好的方法来保护密码?使用Jasypt
怎么样?您使用什么技术来安全地存储用户密码?
编辑:尽管我没有得到非常有趣和详细的答案,但我还是选择了 bcrypt/jBCrypt,因为它似乎是最好的选择。欢迎大家讨论。
I've come to a point when I need to pick a way how to safely keep user passwords in database and to be able to check if they match when user signs in in the website.
I'm using Spring 2.5 at the moment, but upgrading slowly to Spring 3. What would you suggest me to keep the passwords safe? I know this question has been answered in similar forms here and there, but I would like to see some exact, up-to-date answer about how to do that, which could also protect against today's password hacking techniques.
What would be the most appropriate way of hashing passwords with salt? I mean what algorithm to use better if any at all? Should I use bcrypt
instead and is jBCrypt
a good lib for that? Is there any better way how to protect the passwords? What about using Jasypt
? What techniques do you use to store the user passwords safely?
Edit: Even though i didn't get like very interesting and detailish answers I went with bcrypt/jBCrypt as it's seems the best choose. Feel free to discuss.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,您应该使用 bcrypt/jBCrypt。 bcrypt 的设计速度很慢,因此破解密码需要花费极长的时间。
有关额外措施,请参阅此博文您可以在使用 bcrypt 进行密码哈希处理的基础上使用它。
Yes, you should use bcrypt/jBCrypt. bcrypt is specifically designed to be slow, so it would take an infeasible amount of time to crack a password.
See this blog post on extra measures that you can use on top of using bcrypt for password hashing.
SpringSecurity 支持 使用散列和盐进行密码编码。
SpringSecurity supports password encoding using hashing and salts.
你可以使用 md5 对其进行哈希处理
代码:
you can hash it using md5
code: