请解释一下杂音哈希?

发布于 2024-07-26 05:29:51 字数 1437 浏览 2 评论 0原文

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

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

发布评论

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

评论(2

不醒的梦 2024-08-02 05:29:51

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

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

问候

The code is available here .
m and r are constants used by the algorithm.
k *= m means take variable k and multiple it by m.
k ^= k >> r means take k and right shift the bits r places (e.g. if r is 2 110101 would become 001101) and then XOR it with k.

Hope that gives you enough to work through the rest.

Regards

小镇女孩 2024-08-02 05:29:51

Murmur 算法的最佳解释位于Murmur Hash Wikipedia 页面< /a>:

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)

还有我自己的:

在此处输入图像描述

The best explanation of the Murmur algorithm is on the Murmur Hash Wikipedia page:

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)

And my own:

enter image description here

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