CityHash
Google's fast non-cryptographic string hash, optimised for short strings on x86-64
Overview
CityHash is a family of non-cryptographic hash functions released by Google in 2011, designed for fast hashing of strings on 64-bit processors. It was later succeeded at Google by FarmHash. It provides no security against a deliberate attacker.
CityHash64 uses different code paths depending on input length, with specialised routines for 0–16, 17–32, 33–64 and longer inputs. Each path loads 64-bit words, multiplies them by large constants, rotates, shifts and combines them, and a final mixing step derived from MurmurHash produces the output. Its speed comes from wide loads.
NextSSL includes CityHash64 as an entry wired from source and not yet verified against Google's reference outputs. CityHash versions changed outputs over time, so stored values must be matched with the same version. None of this provides security: the function has no secret key, and anyone can compute or deliberately collide its outputs.
History
2011–2011CityHash published by Geoff Pike, Jyrki Alakuijala (Google)
Security notes
CityHash is not cryptographic. Seed-independent collisions have been demonstrated, so it is unsuitable for hash tables exposed to adversarial input or for any security purpose.
Typical uses
Variants in NextSSL
1| Algorithm | Tier | Sizes (bytes) | Standards | API |
|---|---|---|---|---|
| Cityhash cityhash |
unverified | out 8 | CityHash64 (Google), NON-cryptographic | root |
Frequently asked questions
Which CityHash variants does NextSSL include?
NextSSL registers 1 CityHash variant: cityhash.
Families with similar names
Other checksums and non-cryptographic hashes
All 130Related
J. Andrew Rogers's fast 64-bit non-cryptographic hash generated by algorithm search
MurmurHash3Austin Appleby's widely used multiply-rotate hash for hash tables
xxHashYann Collet's extremely fast non-cryptographic hash family: XXH32, XXH64, XXH3 and XXH128
SipHashA short-input keyed PRF designed to protect hash tables from flooding attacks