请解释杂音哈希?

19 algorithm hashtable collision

我刚发现杂音哈希,似乎是最快的已知和相当抗冲突.我试图在完整的源代码中挖掘更多关于算法或实现的内容,但我很难理解它.有人可以在这里解释所使用的算法,或者在完整的源代码中实现它,最好是在C中.我从作者网站上读到了C源代码但是不知道,比如:什么是seed,h,k,m?这是什么意思 :

k *= m; 
k ^= k >> r; 
k *= m; 

h *= m; 
h ^= k;

data += 4;
len -= 4;
Run Code Online (Sandbox Code Playgroud)

???

参考:http://murmurhash.googlepages.com/

抱歉我的英语和我的愚蠢.干杯

Ian*_*oyd 5

Murmur 算法的最佳解释是在Murmur Hash Wikipedia页面上:

Murmur3_32(key, len, seed)
    //Note: In this version, all integer arithmetic is performed 
    //with unsigned 32 bit integers. In the case of overflow, 
    //the result is constrained by the application 
    //of modulo 232 arithmetic.

    c1 ? 0xcc9e2d51
    c2 ? 0x1b873593
    r1 ? 15
    r2 ? 13
    m ? 5
    n ? 0xe6546b64

    hash ? seed

    for each fourByteChunk of key
        k ? fourByteChunk

        k ? k × c1
        k ? (k ROL r1)
        k ? k × c2

        hash ? hash XOR k
        hash ? (hash ROL r2)
        hash ? hash × m + n

    with any remainingBytesInKey
        remainingBytes ? SwapEndianOrderOf(remainingBytesInKey)
        // Note: Endian swapping is only necessary on big-endian machines.

        remainingBytes ? remainingBytes × c1
        remainingBytes ? (remainingBytes ROL r1)
        remainingBytes ? remainingBytes × c2

        hash ? hash XOR remainingBytes

    hash ? hash XOR len

    hash ? hash XOR (hash SHR 16)
    hash ? hash × 0x85ebca6b
    hash ? hash XOR (hash SRH 13)
    hash ? hash × 0xc2b2ae35
    hash ? hash XOR (hash SHR 16)

而我自己的:

在此输入图像描述

  • 这就是代码。确实,相当可读的伪代码,但我仍然不明白“解释”。我知道这些步骤正在做什么,可以用多种语言编写它,但不知道每个步骤对哈希的贡献,例如,数学上的东西。(我仍在寻找一个好的解释;不攻击这个答案或任何东西)。 (3认同)
  • 好吧,它没有以我能理解的方式讲述数学属性……但我可能有点超前了;该图确实帮助我编写了一个版本,而不是查看实际的实现,而不是伪代码,所以谢谢;) (2认同)
  • 图中的第一个计算列:636f7272 和 cc9e2d51 的乘法溢出 32 位,当应用 mod32 时产生 87bd4012,而不是 *0xC1AF97CE*... 对吗? (2认同)

How*_*May 3

该代码可在此处获取。m 和 r 是算法使用的常数。k *= m 表示采用变量 k 并将其乘以 m。k ^= k >> r 表示取 k 并右移 r 位(例如,如果 r 为 2,110101 将变为 001101),然后将其与 k 进行异或。

希望这足以让您完成剩下的工作。

问候