MCPcopy Index your code
hub / github.com/eldruin/wyhash-rs

github.com/eldruin/wyhash-rs @v0.6.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.6.0 ↗ · + Follow
68 symbols 141 edges 20 files 8 documented · 12% updated 13mo agov0.6.0 · 2025-05-23★ 1033 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

wyhash fast portable non-cryptographic hashing algorithm

crates.io Docs MSRV Build Status Coverage Status

Rust implementation of the wyhash algorithm by Wang Yi.

The hashing algorithm passes SMHasher and the random number generator passes BigCrush and practrand. As of now it is the fastest algorithm in the SMHasher benchmark (faster than t1ha and XXH3). See here.

Furthermore, this algorithm is solid, simple, portable (does not need hardware support, can be used in no_std environments) and has no dependencies (except the traits from rand_core).

The generated hashes are equal (see tests) as of the version stated here although the speed varies (PRs are welcome).

Crate features

By default this crate uses 128-bit integer multiplications. To restrict that to 64 bits you can enable the feature mum32bit. This offers better performance on 32-bit architectures. Beware that this feature produces different results.

Usage

This crate provides free functions as well as implementations of the Hasher, BuildHasher, Rng and SeedableRng traits.

use core::hash::Hasher;
use wyhash::WyHash;

fn main() {
  let mut hasher = WyHash::with_seed(3);
  hasher.write(&[0, 1, 2]);
  assert_eq!(0xcc24_2106_e707_6a48, hasher.finish());
}

See further examples of the hasher and RNG in the documentation.

Performance comparison

A basic performance comparison benchmark against [fnv], [twox-hash], [metrohash] and the standard hash_map hash collections::hash_map::DefaultHasher is included in the sources and you can run it with nightly Rust:

cargo +nightly bench

Support

For questions, issues, feature requests, and other changes, please file an issue in the github project.

Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.63.0 and up. It might compile with older versions but that may change in any new patch release.

License

Licensed under either of

  • Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Core symbols most depended-on inside this repo

read64
called by 16
src/v1/functions.rs
wymum
called by 11
src/v1/functions.rs
read32
called by 10
src/v1/functions.rs
write
called by 8
src/v1/traits.rs
wymum
called by 7
src/final3/functions.rs
read64_swapped
called by 7
src/v1/functions.rs
wyhash
called by 5
src/v1/functions.rs
finish
called by 4
src/v1/traits.rs

Shape

Function 41
Method 21
Class 6

Languages

Rust91%
C9%

Modules by API surface

src/v1/traits.rs14 symbols
src/final3/traits.rs13 symbols
src/v1/functions.rs12 symbols
src/final3/functions.rs9 symbols
tests/integration.rs4 symbols
comparison/tests/back_to_back_hash.rs2 symbols
comparison/original/lib_v1.c2 symbols
comparison/original/lib_final3_32bit_mum.c2 symbols
comparison/original/lib_final3.c2 symbols
comparison/benches/bench.rs2 symbols
benches/bench.rs2 symbols
examples/rng_traits.rs1 symbols

For agents

$ claude mcp add wyhash-rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page