32位校验和算法比CRC32质量更好?

发布于 2024-12-20 03:16:33 字数 241 浏览 2 评论 0原文

是否存在具有以下任一功能的 32 位校验和算法:

  • 输入数据大小 < 时哈希冲突概率较小1 KB ?
  • 碰撞的分布更加均匀。

这些与 CRC32 相关。由于 32 位存储空间的限制,我实际上不依赖第一个属性。但对于第二个......似乎可以进行改进。

有什么想法吗?谢谢。 (我需要具体的实现,最好用 C 语言,但 C++/C# 或任何开始的东西也可以)。

Are there any 32-bit checksum algorithm with either:

  • Smaller hash collision probability for input data sizes < 1 KB ?
  • Collision hits with more uniform distribution.

These relative to CRC32. I'm practically not counting on first property, because of limitation of storage space of 32 bits. But for the second ... seems there could be improvements.

Any ideas ? Thanks. (I need concrete implementation, better in C, but C++/ C# or anything to start with is also OK).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

还给你自由 2024-12-27 03:16:33

MurmurHash 怎么样? ,这个哈希具有良好的分布(通过卡方测试)和良好的雪崩影响。计算速度也非常好。

How about MurmurHash? It is said, that this hash has good distribution (passes chi-square tests) and good avalanche effect. Also very good computing speed.

冷了相思 2024-12-27 03:16:33

不符合第一个标准。任何设计良好的具有 32 位输出的哈希函数对于任何输入对都有 1 in 2^32 的冲突机会。第二个标准没有很好地定义,尽管肯定有一些可以使用的统计测试,并且我确信有人已经做到了(碰撞间隔的卡方?)。至于需要实现,我强烈建议您不要接受任何不是众所周知的哈希实现的哈希函数的建议代码,因为在滚动您自己的哈希或加密时存在很高的安全问题或性能不佳的风险。一个众所周知但糟糕的哈希函数比您自己设计的哈希函数更好,即使后者测试良好并且具有“良好”的碰撞分布,仅仅是因为前者更受关注。

Not for the first criteria. Any well designed hash function with a 32 bit output has a 1 in 2^32 chance of a collision for any pair of inputs. The second criteria is not very well defined, although there are surely some statistical tests that could be used, and I'm sure someone has done it (chi-square for collision intervals?). As for needing an implementation, I strongly recommend that you not accept any proposed code for a hash function that is not an implementation of a well known hash, as there is a high risk of security problems or poor performance when rolling your own hash or encryption. A well known but bad hash function is better than one you designed yourself, even if the latter one tests well and has a 'good' collision distribution, simply because the former has more eyeballs on it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文