What's Changed
CircleHash64f is stable and used in production. Given same input data and seed, it will produce same digest in future versions.
- Combine files and simplify file names by @fxamacker in #12
- Update circlehash64_test.go by @fxamacker in #13
- Update README.md and add a logo (circle with a hash symbol inside)
Full Changelog: v0.2.0...v0.3.0
What is CircleHash?
CircleHash is a family of modern non-cryptographic hash functions.
CircleHash64 is a 64-bit hash with a 64-bit seed. CircleHash64 is fast, simple, and easy to audit. It uses the fractional digits of π as default constants (nothing up my sleeve). It balances speed, digest quality, and maintainability.
CircleHash64 is based on Google's Abseil C++ library internal hash. CircleHash64 passes every test in SMHasher (demerphq/smhasher, rurban/smhasher, and a stricter private test suite).
Strict Avalanche Criterion (SAC)
CircleHash64 | Abseil C++ | SipHash-2-4 | XXH64 | |
---|---|---|---|---|
SAC worst-bit 0-128 byte inputs (lower % is better) |
0.791% 🥇 w/ 99 bytes |
0.862% w/ 67 bytes |
0.852% w/ 125 bytes |
0.832% w/ 113 bytes |
☝️ Using demerphq/smhasher updated to test all input sizes 0-128 bytes (SAC test will take hours longer to run).
Hashing Short Inputs With 64-bit Seed
CircleHash64 (seeded) |
XXH3 (seeded) |
XXH64 (w/o seed) |
SipHash (seeded) |
|
---|---|---|---|---|
4 bytes | 1.34 GB/s | 1.21 GB/s | 0.877 GB/s | 0.361 GB/s |
8 bytes | 2.70 GB/s | 2.41 GB/s | 1.68 GB/s | 0.642 GB/s |
16 bytes | 5.48 GB/s | 5.21 GB/s | 2.94 GB/s | 1.03 GB/s |
32 bytes | 8.01 GB/s | 7.08 GB/s | 3.33 GB/s | 1.46 GB/s |
64 bytes | 10.3 GB/s | 9.33 GB/s | 5.47 GB/s | 1.83 GB/s |
128 bytes | 12.8 GB/s | 11.6 GB/s | 8.22 GB/s | 2.09 GB/s |
192 bytes | 14.2 GB/s | 9.86 GB/s | 9.71 GB/s | 2.17 GB/s |
256 bytes | 15.0 GB/s | 8.19 GB/s | 10.2 GB/s | 2.22 GB/s |
- Using Go 1.17.7, darwin_amd64, i7-1068NG7 CPU.
- Fastest XXH64 (written in Go+Assembly) doesn't support seed.
CircleHash64 is ideal for short input sizes <= 512 bytes. It was created when a reliable fast hash for data typically <= 128 bytes was needed. Other designs can hash larger inputs faster at the cost of slower speed for shorter input sizes.
ℹ️ Non-cryptographic hashes should only be used in software designed to properly handle hash collisions. If you require a secure hash, please use a cryptographic hash (like the ones in SHA-3 standard).