Crates.io | twox-hash |
lib.rs | twox-hash |
version | |
source | src |
created_at | 2015-05-09 03:04:03.255761 |
updated_at | 2024-12-09 15:57:24.908629 |
description | A Rust implementation of the XXHash and XXH3 algorithms |
homepage | |
repository | https://github.com/shepmaster/twox-hash |
max_upload_size | |
id | 2059 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A Rust implementation of the xxHash algorithm.
These examples use XxHash64
but the same ideas can be
used for XxHash32
or XxHash3_64
.
use twox_hash::XxHash64;
let seed = 1234;
let hash = XxHash64::oneshot(seed, b"some bytes");
assert_eq!(0xeab5_5659_a496_d78b, hash);
use std::hash::Hasher as _;
use twox_hash::XxHash64;
let seed = 1234;
let mut hasher = XxHash64::with_seed(seed);
hasher.write(b"some");
hasher.write(b" ");
hasher.write(b"bytes");
let hash = hasher.finish();
assert_eq!(0xeab5_5659_a496_d78b, hash);
HashMap
use std::{collections::HashMap, hash::BuildHasherDefault};
use twox_hash::XxHash64;
let mut hash = HashMap::<_, _, BuildHasherDefault<XxHash64>>::default();
hash.insert(42, "the answer");
assert_eq!(hash.get(&42), Some(&"the answer"));
use std::collections::HashMap;
use twox_hash::xxhash64;
let mut hash = HashMap::<_, _, xxhash64::RandomState>::default();
hash.insert(42, "the answer");
assert_eq!(hash.get(&42), Some(&"the answer"));
use std::collections::HashMap;
use twox_hash::xxhash64;
let mut hash = HashMap::with_hasher(xxhash64::State::with_seed(0xdead_cafe));
hash.insert(42, "the answer");
assert_eq!(hash.get(&42), Some(&"the answer"));
name | description |
---|---|
xxhash32 | Include the XxHash32 algorithm |
xxhash64 | Include the XxHash64 algorithm |
xxhash3_64 | Include the XxHash3_64 algorithm |
random | Create random instances of the hashers |
serialize | Serialize and deserialize hasher state with Serde |
std | Use the Rust standard library. Enable this if you want SIMD support in XxHash3_64 |
alloc | Use the Rust allocator library. Enable this if you want to create XxHash3_64 with dynamic secrets |
See benchmarks in the comparison README.
Create your feature branch (git checkout -b my-new-feature
)
Add a failing test.
Add code to pass the test.
Commit your changes (git commit -am 'Add some feature'
)
Ensure tests pass.
Push to the branch (git push origin my-new-feature
)
Create a new Pull Request