Table of Contents

MurmurHash3_32 Class

Definition

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

Computes a 32-bit (4-byte) non-cryptographic hash using the MurmurHash3_x86_32 variant by Austin Appleby. This class cannot be inherited.

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

Remarks

MurmurHash3_32 processes input in 4-byte blocks, applying a pair of multiply-rotate-XOR mixing steps per block, followed by a tail pass for any remaining 1-3 bytes. The output is finalized using FMix32(uint) to ensure strong avalanche properties.

A 32-bit seed may be supplied at construction time to produce independent hash families for identical input, which is useful for building distributed hash tables and bloom filters.

Parameters at a glance.

  • Output size: 32 bits (4 bytes), little-endian.
  • Variant: MurmurHash3_x86_32.
  • Block size: 4 bytes; tail pass for remaining 1-3 bytes.
  • Seed: 32 bits, defaults to 0.

When to choose MurmurHash3_32. The default 32-bit hash for in-memory hash tables and bloom filters. Choose it over Fnv1a32 when input length exceeds ~16 bytes or when SMHasher quality matters. Reach for MurmurHash3_128 when collision pressure (large key spaces, fingerprinting) calls for more bits, or for CityHash32 for slightly better throughput on long inputs on 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;

// Default seed, suitable for an in-memory hash table.
var m = new MurmurHash3_32();
byte[] digest = m.ComputeHash(System.Text.Encoding.UTF8.GetBytes("hash-table-key"));

// Custom seed for a second, independent hash family (useful in bloom filters).
var m2 = new MurmurHash3_32(seed: 0x9E3779B1u);
byte[] digest2 = m2.ComputeHash(System.Text.Encoding.UTF8.GetBytes("hash-table-key"));

Constructors

MurmurHash3_32()

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

public MurmurHash3_32()

MurmurHash3_32(uint)

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

public MurmurHash3_32(uint seed)

Parameters

seed uint

The 32-bit seed value used to initialize the hash state.

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