两个不同的字符串可以生成相同的MD5哈希码吗? [英] Can two different strings generate the same MD5 hash code?

查看:2408
本文介绍了两个不同的字符串可以生成相同的MD5哈希码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我们的每个二进制资源,我们生成一个MD5哈希。这用于检查某个二进制资产是否已经在我们的应用程序中。但是有可能两个不同的二进制资产生成相同的MD5哈希。那么有可能两个不同的字符串生成相同的MD5哈希?

For each of our binary assets we generate a MD5 hash. This is used to check whether a certain binary asset is already in our application. But is it possible that two different binary assets generate the same MD5 hash. So is it possible that two different strings generate the same MD5 hash?

推荐答案

对于一组甚至数十亿的资产,随机冲突的机会可以忽略不计 - 没有什么你应该担心。考虑到生日悖论,给定一组2 ^ 64(或18,446,744,073,709,551,616)资产,概率的单位 MD5冲突在此集合内为50%。

For a set of even billions of assets, the chances of random collisions are negligibly small -- nothing that you should worry about. Considering the birthday paradox, given a set of 2^64 (or 18,446,744,073,709,551,616) assets, the probability of a single MD5 collision within this set is 50%. At this scale, you'd probably beat Google in terms of storage capacity.

但是,由于MD5散列函数已被破坏(它容易受到碰撞攻击),任何确定的攻击者可在几秒钟内产生2个冲突资产值得CPU的力量。所以,如果你想使用MD5,请确保这样的攻击者不会危及你的应用程序的安全!

However, because the MD5 hash function has been broken (it's vulnerable to a collision attack), any determined attacker can produce 2 colliding assets in a matter of seconds worth of CPU power. So if you want to use MD5, make sure that such an attacker would not compromise the security of your application!

此外,考虑如果攻击者可以伪造与数据库中现有资产的冲突。虽然没有针对MD5(截至2011年)的此类已知攻击( preimage攻击),但可以通过扩展当前的冲突攻击研究成为可能。

Also, consider the ramifications if an attacker could forge a collision to an existing asset in your database. While there are no such known attacks (preimage attacks) against MD5 (as of 2011), it could become possible by extending the current research on collision attacks.

如果这是一个问题,我建议看看SHA-2系列的哈希函数-256,SHA-384和SHA-512)。缺点是它稍慢,有更长的散列输出。

If these turn out to be a problem, I suggest looking at the SHA-2 series of hash functions (SHA-256, SHA-384 and SHA-512). The downside is that it's slightly slower and has longer hash output.

这篇关于两个不同的字符串可以生成相同的MD5哈希码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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