#hash #hashing #bindings #algorithm #xx-hash #64-bit #libxxhash

xxhash2

Bindings to libxxhash to provide the xxHash algorithm in Rust. Also contains an implementation of the std::hash traits so this can be used with the standard HashMap.

1 unstable release

Uses old Rust 2015

0.1.0 Mar 17, 2016

#5 in #xx-hash

Download history 1/week @ 2023-11-20 5/week @ 2023-11-27 3/week @ 2024-01-08 9/week @ 2024-02-05 9/week @ 2024-02-12 92/week @ 2024-02-19 37/week @ 2024-02-26 20/week @ 2024-03-04

159 downloads per month
Used in 2 crates

MIT/Apache

15KB
235 lines

xxhash2

Build Status Build status

Documentation

Bindings to the official libxxhash implementation in Rust.

# Cargo.toml
[dependencies]
xxhash2 = "0.1"

License

xxhash2-rs is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, and LICENSE-MIT for details.


lib.rs:

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);

Dependencies

~42KB