hayahash

Fast, portable 64- and 128-bit hashing for hash tables, caches, and checksums. One C header, with matching results across ten language ports.

Experimental and non-cryptographic. Hash values may change between releases. Avoid uses that need stable hashes across versions. Do not use hayahash for security. Stability policy.

Get started · Try it in your browser · Source on GitHub

Get started

Copy hayahash.h into your C or C++ project. No dependencies.

#include "hayahash.h"

uint64_t h = hayahash64("hello", 5, 0);  // seed = 0
hayahash128_t h128 = hayahash128("hello", 5, 0);
// h128.lo == h; h128.hi is the second word

Choose your language: C / C++, Rust, Go, Zig, Java, C#, Python, Swift, JavaScript / TypeScript, Haskell, or MIPS64. See the streaming example for input that arrives in chunks.

For files and stdin, build the hayasum CLI with make -C cli.

Performance

hayahash is designed for environments such as WebAssembly where hardware acceleration cannot be assumed. Native hashes using wide multiplication, SIMD, or AES can be faster; measure your workload.

1 MiB input, GB/s (higher is better)
host / compiler64-bit128-bit
Apple M1 Pro / Apple clang 2130.7330.76
Ryzen AI 9 HX PRO 370 / GCC 1661.4761.31
wasm32 on M1 Pro / Zig 0.1623.5523.34

Both widths have similar bulk throughput in these runs. Ryzen bulk uses compiler auto-vectorization; the wasm build uses no SIMD. Comparisons, small-input timings, and methodology.

Tested across languages and platforms

Both widths pass all 188 default tests of the pinned SMHasher3 suite. CI checks ports against the C reference, including streaming and byte-order consistency. Passing these tests does not make a hash cryptographically secure. Test coverage and limitations.

How it works

Short inputs use a dedicated path. Larger inputs are mixed across parallel lanes, then combined into a digest. Both widths share the same pass over the input; the 128-bit result adds a second output word. Explore the design and step through it.

License

The header and ports are public domain under the Unlicense. The separate SMHasher3 test adapter is GPL-3.0-or-later and is not included in release artifacts.