我可以使用Knuth散列为byte[]生成唯一的散列号吗?
通常的Knuth Hash算法如下所示:
int KnuthHsh(int v)
{
v *= 2654435761;
return v >> 32;
}是否也有一种方法可以输入byte[]并为其生成唯一的哈希值?
发布于 2022-03-08 18:11:18
public static ulong CalculateHash(byte[] bytes)
{
var hashedValue = 3074457345618258791UL;
foreach (var b in bytes)
{
hashedValue += b;
hashedValue *= 3074457345618258799UL;
}
return hashedValue;
}https://stackoverflow.com/questions/30445546
复制相似问题