最好的32位哈希函数短字符串(标签名)是什么?最好的、字符串、函数、标签

2023-09-10 23:47:30 作者:陌上少年

最好的32位哈希函数相对较短的字符串是什么?

What is the best 32bit hash function for relatively short strings?

字符串是标记名称是包含英文字母,数字,空格和一些其他字符(#, $ ,...)。例如:单元测试 C#2.0

Strings are tag names that consist of English letters, numbers, spaces and some additional characters (#, $, ., ...). For example: Unit testing, C# 2.0.

我在寻找最佳作为最小的冲突,表现不是我的目标很重要。

I am looking for 'best' as in 'minimal collisions', performance is not important for my goals.

推荐答案

如果性能并不重要,简单地采取安全哈希如MD5或SHA-1,并截断其输出为32位。这会给你的散列codeS这是随机难以区分的分布。

If performance isn't important, simply take a secure hash such as MD5 or SHA1, and truncate its output to 32 bits. This will give you a distribution of hash codes that's indistinguishable from random.