siphasher
A Rust implementation of the SipHash 2-4, 1-3, and 128-bit keyed hash functions.
Repository Health
Technical Analysis
siphasher is a Rust crate that implements the SipHash family of fast, keyed pseudorandom hash functions, including SipHash-2-4, SipHash-1-3, and 128-bit tag variants. It is based on the original implementation from rust-core and exposes the same familiar API, making it a drop-in choice for keyed hashing.
SipHash is designed to be fast for short inputs while resisting hash-flooding denial-of-service attacks, which is why it underpins hash-map keying in many systems. The crate offers both one-shot and incremental hashing through the standard Hasher trait, works in no_std environments, and optionally supports serde.
What You Get
- SipHash-2-4 and SipHash-1-3 implementations in 64-bit mode
- 128-bit output variants via the
sip128module - Keyed construction with a 16-byte key for DoS-resistant hashing
- One-shot and incremental hashing through the standard
Hashertrait - no_std compatibility and optional serde support
Common Use Cases
- Keying hash maps and sets to resist hash-flooding attacks
- Fast checksums and fingerprints for short byte inputs
- Deterministic, keyed hashing across platforms
- Hashing in embedded or no_std Rust projects
Under The Hood
Architecture - The crate is small and focused: sip.rs implements the 64-bit SipHasher variants, sip128.rs the 128-bit variants and the Hasher128 trait, and common.rs holds the shared SipHash round logic (state words, compression rounds) reused by both. The public surface in lib.rs re-exports these modules, and each hasher plugs into the standard core::hash::Hasher interface so it works with the wider Rust hashing ecosystem.
Tech Stack - Pure Rust (edition 2018) with no required runtime dependencies for the core; serde support is gated behind an optional feature. The implementation is #![no_std]-capable, relying only on core.
Code Quality - Despite its small size the crate ships dedicated test files (tests.rs, tests128.rs) covering both output widths against known SipHash test vectors, and it derives from the well-audited rust-core reference implementation. The round logic is centralized in common.rs to avoid duplication between the 64- and 128-bit paths.
API Design - The API mirrors the standard-library Hasher and is deliberately minimal: construct with a key, then either hash() a slice or write()/finish() incrementally. Matching the original rust-core API means low friction for anyone who has used Rust’s default hashers, and the README’s copy-paste examples make onboarding almost instant.
Used by 2 apps in this directory
InfluxDB
Databases · Analytics
Open-source time-series database built for real-time ingest, fast SQL queries, and embedded Python automation — powered by Apache Arrow and Parquet.
Qdrant
Databases · AI Development · Search
Open-source vector database and search engine built in Rust for production-grade AI applications — from semantic search to RAG pipelines and recommendation systems.