是前32位的160位SHA1哈希的可以替代的CRC32哈希? [英] Are the first 32 bits of a 160-bit SHA1 hash an acceptable substitute for a CRC32 hash?

查看:122
本文介绍了是前32位的160位SHA1哈希的可以替代的CRC32哈希?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个.NET 3.5的项目,我需要一个32位的哈希值。似乎没有由该返​​回一个32位散列的.NET加密的类的任何方法(MD5是128位,SHA1是160位等)。我实现了一个CRC32类,但我发现,SHA1和MD5哈希已经存在快得多。

I'm working on a .NET 3.5 project and I need a 32-bit hash value. There doesn't seem to be any methods in the .NET Cryptography classes that return a 32-bit hash (MD5 is 128 bits, SHA1 is 160 bits, etc.). I implemented a CRC32 class, but I find that the SHA1 and MD5 hashing functions that already exist are much faster.

会不会有什么问题(即碰撞的机会增加),与使用SHA1散列函数,只掰了前32位保存为我的哈希值?我

Would there be any problem (i.e., increased chance of collisions) with me using the SHA1 hashing function and just breaking off the first 32 bits to store as my hash value?

推荐答案

除非你想要的CRC32的额外功能(即线性code),你应该罚款与切割输出到32位。

Unless you want the extra features of the CRC32 (being a linear code), you should be fine with cutting the output to 32 bit.

无论是切割的一些加密哈希函数的输出伤害它的安全性就抗碰撞是一个开放的研究课题(不自然构成的例子存在,如果我没记错的话)。但是,NIST(可能与美国国家安全局的批准)中使用的切割技术得到了SHA-224 SHA-256呢(见的维基百科文章关于SHA)。

Whether cutting the output of some cryptographic hash-functions hurts its security with respect to collision resistant is an open research problem ("unnatural" constructed examples exist if I remember correctly). But NIST (probably with the approval of the NSA) used the cutting technique to get the SHA-224 from SHA-256 anyway (see article about SHA in wikipedia).

编辑:在CRC32允许检测(也许是正确的)单比特错误,而加密散列函数应该有,你不能找到两个输入,具有相同的哈希值的属性。

the CRC32 allows to detect (and maybe correct) single bit errors, whereas a cryptographic hash function should have the property that you can't find two inputs that have the same hash value.

您知道生日悖论(见再次维基百科)?随着32位校验你希望得到一个冲突(即两个输入具有相同的哈希值)时,你有2 ^ 16个输入,并且想散列更多的投入。 (重读你的评论这可能不是你的问题。)

Are you aware of the "birthday paradox" (see again wikipedia)? With an 32-bit checksum you expect to get a collision (i.e., two inputs with the same hash value) when you have about 2^16 inputs, and you want to hash many more inputs. (Rereading your comment this might not be a problem for you.)

这篇关于是前32位的160位SHA1哈希的可以替代的CRC32哈希?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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