Crate mur3

Source
Expand description

A rust implementation of MurmurHash3.

To use the crate, add it as dependency:

[dependency]
mur3 = "0.1"

To calculate a hash of a byte slices, just use function version of the APIs:

let bytes = b"hello world";
let seed = 0;
let (h1, h2) = mur3::murmurhash3_x64_128(bytes, seed);

If there are a lot of byte slices, you can also feed them using Hasher. Hasher version is a little slower than the function version, but more flexible.

use std::hash::Hasher;

let bytes: &[&[u8]] = &[b"hello", b"world"];
let seed = 0;

let mut hasher = mur3::Hasher128::with_seed(seed);
for b in bytes {
    hasher.write(b);
}
let (h1, h2) = hasher.finish128();

The library can be used in no_std freely.

Structs§

Hasher32
A 32-bit Murmur3 hasher.
Hasher128
A 128-bit Murmur3 hasher.

Functions§

murmurhash3_x64_128
Gets the 128-bit MurmurHash3 sum of data.
murmurhash3_x86_32
Gets the 32-bit MurmurHash3 sum of data.