Crate xxhash2 [] [src]

Bindings to libxxhash, an xxHash implementation.

This library contains safe Rust bindings to the libxxhash library which contains an implementation of the xxHash algorithm. There are Rust implementations available of this hash algorithm, but it is intended that this library is a binding to the official C source.

The xxHash algorith comes in 32 and 64 bit variants. reflected in the exported types and functions of this crate.

Examples

assert_eq!(xxhash2::hash32(&[1, 2, 3, 4], 0), 4271296924);
assert_eq!(xxhash2::hash64(&[1, 2, 3, 4], 0), 6063570110359613137);

let mut s = xxhash2::State32::new();
s.reset(0);
s.update(&[1, 2, 3, 4]);
assert_eq!(s.finish(), 4271296924);

let mut s = xxhash2::State64::new();
s.reset(0);
s.update(&[1, 2, 3, 4]);
assert_eq!(s.finish(), 6063570110359613137);

Structs

Hash32

Canonical representation of a 32-bit hash.

Hash64

Canonical representation of a 64-bit hash.

State32

Representation of the intermediate state of a 32-bit xxHash instance.

State64

Representation of the intermediate state of a 64-bit xxHash instance.

Functions

hash32

Hash a block of bytes with a given seed, returning the 32-bit hash.

hash64

Hash a block of bytes with a given seed, returning the 64-bit hash.