siphasher

A Rust implementation of the SipHash 2-4, 1-3, and 128-bit keyed hash functions.

Library
Cargo
v1.0.3
75stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
37/100Needs Attention
Development Activity28
Maintenance4
Community44
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture82
Code Quality84
Innovation70
Learning Curve82

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 sip128 module
  • Keyed construction with a 16-byte key for DoS-resistant hashing
  • One-shot and incremental hashing through the standard Hasher trait
  • 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.

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