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

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

问题描述

我正在开发一个.NET 3.5项目,我需要一个32位的哈希值。在.NET Cryptography类中似乎没有返回32位散列的任何方法(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的额外功能(是一个线性代码),你应该把输出切割成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(可能得到NSA的批准)使用切割技术从SHA-256得到SHA-224(见关于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.)

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

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