xxhash-rust

Pure-Rust implementation of the XXH32, XXH64, and XXH3 hash algorithms

Library
Cargo
v0.8.18
293stars
BSL-1.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
54/100Fair
Development Activity56
Maintenance24
Community56
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture76
Code Quality78
Innovation68
Learning Curve72

xxhash-rust is a from-scratch, pure-Rust reimplementation of the xxHash family of non-cryptographic hash algorithms (XXH32, XXH64, and the newer XXH3), used for fast checksumming, hash-map keys, and content-addressing where cryptographic security isn’t required. Unlike bindings that link against the C xxHash library, this crate is written entirely in Rust with no C dependency, and supports no_std environments (with an optional alloc-free mode) for embedded and constrained targets.

Each algorithm variant is feature-gated (xxh32, xxh64, xxh3) so consumers only compile the hash functions they actually use, and const-context variants (const_xxh32, const_xxh64, const_xxh3) allow computing hashes at compile time. It’s a widely-depended-on building block across the Rust ecosystem for fast hashing where allocation-free, no-std-compatible code is required.

What You Get

  • Pure-Rust implementations of XXH32, XXH64, and XXH3 with no C library dependency
  • Feature-gated compilation (xxh32, xxh64, xxh3) so you only build the variants you actually use
  • no_std support, including a no-allocation mode suitable for embedded and constrained environments
  • Const-context hashing (const_xxh32, const_xxh64, const_xxh3) for computing hashes at compile time
  • Optional std::io::Write implementation (via the std feature) for streaming hash computation over readers/writers

Common Use Cases

  • Fast, non-cryptographic checksumming of files or network payloads where speed matters more than cryptographic security
  • Hashing keys for high-performance hash maps/sets that don’t need collision-resistance guarantees
  • Compile-time hash computation (e.g. for perfect hash tables or static lookup keys) via the const-context variants
  • Content-addressing or deduplication in no_std embedded firmware where a C xxHash dependency isn’t viable
  • Cache-key generation for build tools and asset pipelines needing a fast, stable hash of file contents

Under The Hood

Architecture - The crate is organized as one Rust module per algorithm variant: xxh32.rs, xxh64.rs, and the larger xxh3.rs (~1,640 lines, the most complex due to XXH3’s SIMD-friendly design and secret/seed handling), each paired with a const_* sibling module implementing the same algorithm in a const fn-compatible style for compile-time evaluation; shared constants and utility bit-manipulation helpers live in *_common.rs and utils.rs. Tech Stack - Pure Rust (2018 edition) with zero mandatory dependencies; the crate is entirely no_std-compatible with an additional no-allocation mode, and dev-dependencies include xxhash-c-sys (the official C bindings) purely to cross-validate output correctness against the reference implementation in tests. Code Quality - Correctness is validated with 4 integration test files that compare this pure-Rust implementation’s output byte-for-byte against the canonical C xxHash library via xxhash-c-sys, plus a valgrind.supp suppression file indicating the maintainer runs memory-safety tooling in CI. API Design - The API mirrors Rust’s standard hashing conventions (implementing core::hash::Hasher where applicable) while also exposing simple one-shot functions (e.g. xxh3::xxh3_64(bytes)) for the common case, so consumers can pick either the streaming Hasher trait or a direct function call depending on their use case.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search