哈希密码时最好的 2 种算法是什么?
我想使用 2 个不同的哈希值来存储密码(为同一密码保存 2 个哈希值,以通过(几乎)消除冲突来(稍微)提高安全性。 第一个问题:既然碰撞可以忽略不计,那么首先这样做是否有足够的好处? 第二个问题:最好的哈希值是什么? sha-1 和 sha-256 是否比 sha-256 和一些不相关的算法(如blowfish)有更多的碰撞?
I want to store my passwords using 2 different hashes (saving 2 hashes for the same password to (slightly) increase security by (almost) eliminating collisions.
first question: is there enough of an upside for this in the first place since collisions are negligible anyway ?
second question: what would the best hashes for this be ? do sha-1 and sha-256 have more collisions than sha-256 and some unrelated algorithm like blowfish ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我理解正确,您想在数据库中使用两种不同的哈希算法将哈希密码存储两次,是吗?只需使用两个产生不同长度的哈希算法,两个不同哈希之间根本不会发生冲突。
例如 sha1 和 md5 提供不同长度的输出。
If I understand you correct you want to store the hashed password two times with two different hashing algorithms in your database yes? Simply use two hashalgorithms producing a different length and there is no chance of collision between the two different hashes at all.
For instance sha1 and md5 provide different lengths of output.
我建议使用 sha1 并且不用担心冲突。 sha1 冲突的可能性为 10^-45(如此处所述 SHA1 冲突的概率) ,所以除非你拥有数十亿用户,否则这永远不会成为问题。
I would recommend using a sha1 and not worrying about collisions. The likelyhood of a sha1 collision is 10^-45 (as explained here Probability of SHA1 collisions), so unless you will have billions of users, it will never be an issue.