encyclopegia.org

MurmurHash

MurmurHash is a non-cryptographic hash function suitable for general hash-based lookup.[src] It was created by Austin Appleby in 2008 and, as of 8 January 2016, is hosted on GitHub along with its test suite named SMHasher.[src] It also exists in a number of variants, all of which have been released into the public domain.[src] The name comes from two basic operations, multiply (MU) and rotate (R), used in its inner loop.[src] Unlike cryptographic hash functions, it is not specifically designed to be difficult to reverse by an adversary, making it unsuitable for cryptographic purposes.[src]

MurmurHash is a non-cryptographic hash function suitable for general hash-based lookup.[src] It was created by Austin Appleby in 2008 and, as of 8 January 2016, is hosted on GitHub along with its test suite named SMHasher.[src] It also exists in a number of variants, all of which have been released into the public domain.[src] The name comes from two basic operations, multiply (MU) and rotate (R), used in its inner loop.[src] Unlike cryptographic hash functions, it is not specifically designed to be difficult to reverse by an adversary, making it unsuitable for cryptographic purposes.[src] ==Variants== ===MurmurHash1=== The original MurmurHash was created as an attempt to make a faster function than Lookup3.[src] Although successful, it had not been tested thoroughly and was not capable of providing 64-bit hashes as in Lookup3.[src] Its design would be later built upon in MurmurHash2, combining a multiplicative hash (similar to the Fowler–Noll–Vo hash function) with an Xorshift.[src] ===MurmurHash2=== MurmurHash2 yields a 32- or 64-bit value.[src] It comes in multiple variants, including some that allow incremental hashing and aligned or neutral versions.[src] MurmurHash2 (32-bit, x86)—The original version; contains a flaw that weakens collision in some cases.[src] MurmurHash2A (32-bit, x86)—A fixed variant using Merkle–Damgård construction.[src] Slightly slower.[src] CMurmurHash2A (32-bit, x86)—MurmurHash2A, but works incrementally.[src] MurmurHashNeutral2 (32-bit, x86)—Slower, but endian- and alignment-neutral.[src] MurmurHashAligned2 (32-bit, x86)—Slower, but does aligned reads (safer on some platforms).[src] MurmurHash64A (64-bit, x64)—The original 64-bit version.[src] Optimized for 64-bit arithmetic.[src] MurmurHash64B (64-bit, x86)—A 64-bit version optimized for 32-bit platforms.[src] It is not a true 64-bit hash due to insufficient mixing of the stripes.[src] The person who originally found the flaw in MurmurHash2 created an unofficial 160-bit version of MurmurHash2 called MurmurHash2_160.[src] ===MurmurHash3=== The current version, completed April 3, 2011, is MurmurHash3, which yields a 32-bit or 128-bit hash value.[src] When using 128-bits, the x86 and x64 versions do not produce the same values, as the algorithms are optimized for their respective platforms.[src] MurmurHash3 was released alongside SMHasher, a hash function test suite.[src] ==Implementations== The canonical implementation is in C++, but there are efficient ports for a variety of popular languages, including Python, C, Go, C#, D, Lua, Perl, Ruby, Rust, PHP, Common Lisp, Haskell, Elm, Clojure, Scala, Java, Erlang, Swift, Object Pascal, Kotlin, JavaScript, OCaml and Microsoft Excel.[src] It has been adopted into a number of open-source projects, most notably libstdc++ (ver 4.6), nginx (ver 1.0.1), Rubinius, libmemcached (the C driver for Memcached), npm (nodejs package manager), maatkit, Hadoop, Kyoto Cabinet, Cassandra, Solr, vowpal wabbit, Elasticsearch, Guava, Kafka, and RedHat Virtual Data Optimizer (VDO).[src] ==Vulnerabilities== Hash functions can be vulnerable to collision attacks, where a user can choose input data in such a way so as to intentionally cause hash collisions.[src] Jean-Philippe Aumasson and Daniel J.[src] Bernstein were able to show that even implementations of MurmurHash using a randomized seed are vulnerable to so-called HashDoS attacks.[src] With the use of differential cryptanalysis, they were able to generate inputs that would lead to a hash collision.[src] The authors of the attack recommend using their own SipHash instead.[src] ==Algorithm== algorithm Murmur3_32 is // Note: In this version, all arithmetic is performed with unsigned 32-bit integers.[src] // In the case of overflow, the result is reduced modulo .[src] input: key, len, seed c1 ← 0xcc9e2d51 c2 ← 0x1b873593 r1 ← 15 r2 ← 13 m ← 5 n ← 0xe6546b64 hash ← seed for each fourByteChunk of key do 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 do remainingBytes ← SwapToLittleEndian(remainingBytesInKey) // Note: Endian swapping is only necessary on big-endian machines.[src] // The purpose is to place the meaningful digits towards the low end of the value, // so that these digits have the greatest potential to affect the low range digits // in the subsequent multiplication.[src] Consider that locating the meaningful digits // in the high range would produce a greater effect upon the high digits of the // multiplication, and notably, that such high digits are likely to be discarded // by the modulo arithmetic under overflow.[src] We don't want that.[src] remainingBytes ← remainingBytes × c1 remainingBytes ← remainingBytes ROL r1 remainingBytes ← remainingBytes × c2 hash ← hash XOR remainingBytes hash ← hash XOR len hash ← hash XOR (hash >> 16) hash ← hash × 0x85ebca6b hash ← hash XOR (hash >> 13) hash ← hash × 0xc2b2ae35 hash ← hash XOR (hash >> 16) A sample C implementation follows (for little-endian CPUs): static inline uint32_t murmur_32_scramble(uint32_t k) { k *= 0xcc9e2d51; k = (k > 17); k *= 0x1b873593; return k; } uint32_t murmur3_32(const uint8_t* key, size_t len, uint32_t seed) { uint32_t h = seed; uint32_t k; /* Read in groups of 4.[src] */ for (size_t i = len >> 2; i; i--) { // Here is a source of differing results across endiannesses.[src] // A swap here has no effects on hash properties though.[src] memcpy(&k, key, sizeof(uint32_t)); key += sizeof(uint32_t); h ^= murmur_32_scramble(k); h = (h > 19); h = h * 5 + 0xe6546b64; } /* Read the rest.[src] */ k = 0; for (size_t i = len & 3; i; i--) { k > 16; h *= 0x85ebca6b; h ^= h >> 13; h *= 0xc2b2ae35; h ^= h >> 16; return h; } ==References== ==External links== Official SMHasher site[src]

47 sentences · 47 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"MurmurHash." encyclopegia.org, 2026, https://encyclopegia.org/wiki/murmurhash. Accessed 25 November 2026.

Chicago

"MurmurHash." encyclopegia.org. Accessed November 25, 2026. https://encyclopegia.org/wiki/murmurhash.

APA

encyclopegia.org. (2026). MurmurHash. Retrieved November 25, 2026, from https://encyclopegia.org/wiki/murmurhash

Accessed November 25, 2026 · CC BY-SA 4.0 · citation page · JSON

CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1369877394 · 0.5 · snapshot enwiki-001369877394

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.