比较基于散列与"Guid.NewGuid()"的GUID时,碰撞的可能性更大吗? [英] Is there a greater chance to collide when comparing GUIDs based on a hash vs "Guid.NewGuid()?

查看:145
本文介绍了比较基于散列与"Guid.NewGuid()"的GUID时,碰撞的可能性更大吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的后续操作>比较不同创建的GUID时是否有更大的碰撞机会?.

我有这样的东西:

using( MD5 md5 = MD5.Create() ) {
    var hash = md5.ComputeHash( foo );
    var hashguid = new Guid( hash );
}

这保证了相同的foo会引起GUID冲突,并允许过滤foo的重复项.

This guarantees the same foo will cause a GUID collision, and allows filtering of duplicates of foo.

是否有人担心hashguid更有可能与Guid.NewGuid()生成的GUID(相对于Guid.NewGuid()生成的两个GUID)发生冲突?

Is there any concerns that hashguid has a greater chance to collide with GUIDs generated with Guid.NewGuid() (vs. two GUIDs generated with Guid.NewGuid())?

推荐答案

与哈希输入的碰撞几率相比,加密强度高的哈希算法不会显着增加碰撞几率.这很安全.

Cryptographically strong hash algorithms do not increase the chance of collision significantly when compared to the chance of collision for the hash input. This is safe.

通过以某种方式构造导板并没有实际降低碰撞风险.随机生成的Guid的碰撞机会非常低,以至于火星漫游者也可以依靠它而不会发生.

There is no practical reduction of collision risk by structuring a guid in a certain way. The collision chance of randomly generated guids is so low that even the Mars Rover can rely on that not to happen.

MD5是坏算法,我不会称其为加密强.我不明白为什么人们仍然使用MD5.打破十年后,这不是常识吗?考虑使用SHA256并将输出截断为128位.

MD5 is a broken algorithm and I would not call it cryptographically strong. I don't understand why people still use MD5. Isn't this common knowledge 10 years after the breaking?! Consider using SHA256 and truncating the output to 128 bits.

这篇关于比较基于散列与"Guid.NewGuid()"的GUID时,碰撞的可能性更大吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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