Table of Contents

MurmurHash3_128 Class

Definition

Namespace
Bodu.IO.Hashing
Assembly
Bodu.IO.Hashing.dll
Package
Bodu.IO.Hashing 1.0.0
Source
MurmurHash3.128.cs

Computes a 128-bit (16-byte) non-cryptographic hash using the MurmurHash3_x64_128 variant by Austin Appleby, optimized for 64-bit platforms. This class cannot be inherited.

public sealed class MurmurHash3_128 : MurmurHash3, IDisposable
Inheritance
MurmurHash3_128
Implements
Inherited Members
Extension Methods

Remarks

MurmurHash3_128 maintains two independent 64-bit accumulators (h1 and h2) seeded from the constructor-supplied value. Input is consumed in 16-byte blocks; each block word is mixed through multiply-rotate-multiply passes before being folded into the appropriate accumulator. Remaining 1-15 bytes are handled by a tail switch. Both accumulators are cross-mixed and finalized via FMix64(ulong) to produce the 128-bit output.

A 32-bit seed may be supplied at construction time. Both accumulators are initialized to the same seed value, matching the behavior of the reference MurmurHash3_x64_128 implementation.

Parameters at a glance.

  • Output size: 128 bits (16 bytes), little-endian.
  • Variant: MurmurHash3_x64_128 - optimized for 64-bit platforms.
  • Block size: 16 bytes; tail pass for remaining 1-15 bytes.
  • Seed: 32 bits, applied to both accumulators; defaults to 0.

When to choose MurmurHash3_128. Pick this when collision pressure makes 32 or 64 bits inadequate - content fingerprinting, deduplication keys, large bloom filters. Output is also useful as a pair of 64-bit halves for two-hash cuckoo or split-key schemes. CityHash128 is a comparable alternative with similar quality and slightly better throughput on long inputs on modern 64-bit CPUs.

important

This algorithm is not cryptographically secure and must not be used for password hashing, digital signatures, or any application requiring adversarial collision resistance.

using Bodu.IO.Hashing;
using Bodu.IO.Hashing.Extensions;

// 128-bit fingerprint of a content blob.
var m = new MurmurHash3_128();
byte[] fingerprint = m.ComputeHash(blob);

// Custom seed to isolate a second hash family for cuckoo / bloom-filter use.
var m2 = new MurmurHash3_128(seed: 0xC2B2AE35u);

Constructors

MurmurHash3_128()

Initializes a new instance of the MurmurHash3_128 class with a seed of zero.

public MurmurHash3_128()

MurmurHash3_128(uint)

Initializes a new instance of the MurmurHash3_128 class with the specified seed.

public MurmurHash3_128(uint seed)

Parameters

seed uint

The 32-bit seed value used to initialize both 64-bit accumulators.

Methods

Dispose(bool)

Releases the resources used by the current instance, optionally clearing managed state.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true when called from Dispose(); false when called from a finalizer. Managed resources are released only when disposing is true.

Remarks

Override in a derived class to release additional resources owned by the subclass. Always invoke base.Dispose(disposing) from the override so that the buffered state is cleared.

Applies to

ProductVersions
.NET8, 10

See Also