Library:xxHash
Appearance
| On this wiki | Facts · Code · Notes · Topics |
|---|
Yann Collet's extremely fast non-cryptographic hash family (XXH32, XXH64, XXH3-64, XXH3-128; C, BSD-2-Clause for the library): used for checksums in Zstandard and LZ4 frames, archives and databases; its primes and XXH3 secret identify it in binaries.
Identification
- Single header
xxhash.h(plusxxhash.c,xxh3.h) at https://github.com/Cyan4973/xxHash, library under BSD-2-Clause, command line tool xxhsum under GPL-2.0. - XXH32/XXH64 prime constants (see Fact:xxHash/identification/XXH32 and XXH64 primes) appear as immediates in the code; XXH3 has a 192-byte default secret table starting
B8 FE 6C 39 23 A4 4B BE 7C 01 81 2C F7 21 AD 1C, and mixing constants 0x165667919E3779F9 and 0x9FB21C651E98DF25. - Used as the content checksum of Zstandard frames (the low 4 bytes of XXH64 of the decoded data, seed 0, little-endian;
doc/zstd_compression_format.md, section Content_Checksum, facebook/zstd commit 49cf51799ea051457f57243527aa2058f999f005) and of LZ4 frames (XXH32 of the decoded data, seed 0,doc/lz4_Frame_format.mdlines 91-96, lz4/lz4 commit aa787570e681c695fc087b4a44cd2d5b38c2289a). The LZ4 frame header checksum byte is the second byte of XXH32 of the frame descriptor,(xxh32()>>8) & 0xFF(same file, line 246), not a checksum of the content. - Names exported: XXH32, XXH64, XXH3_64bits, XXH3_64bits_withSeed, XXH3_128bits, XXH32_createState, XXH_versionNumber (statically linked builds keep them as symbols only when not stripped).
Test vectors
The repository's tests/sanity_test_vectors.h has the reference outputs (XXH32 empty input seed 0 0x02CC5D05, seed 0x9E3779B1 0x36B78AE7; XXH64 empty seed 0 0xEF46DB3751D8E999). The vectors use a fixed pseudo-random buffer, so they are for cross-checking an implementation, not for testing with ASCII strings.
Code & repositories
- https://github.com/Cyan4973/xxHash @
680bf463fa1ca0461b9a7c2dab7556e1f54cf4cf· license: BSD-2-Clause (declared by the contributor for the files used; GitHub reports BSD-2-Clause (read from LICENSE; GitHub's detector did not classify it) for the repository)
xxHash reference implementation and sanity test vectors (library BSD-2-Clause).
Tested on: source read, not run: files read: xxhash.h, tests/sanity_test_vectors.h · checked 2026-10-18; last activity 2026-10-13; Note: the latest release ships binaries; the wiki links only the source, never the binaries