Cityhash
Google's fast non-cryptographic string hash, optimised for short strings on x86-64
Source found and wired, correctness not fully proven. Root API only. Reach it with NextSSL(root=True) in Python or the nextssl_root_* functions in C.
About Cityhash
Cityhash is a checksum / non-cryptographic hash. It produces an 8-byte (64-bit) output. Its registry entry cites CityHash64 (Google), NON-cryptographic. NextSSL lists it in the unverified tier and exposes it through the root API only (NextSSL(root=True) in Python, nextssl_root_* in C).
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
Sizes
| Field | Bytes | Meaning |
|---|---|---|
| out | 8 | Output |
Use it
from nextssl_demo import NextSSL
root = NextSSL(root=True) # tier 'unverified' is reachable from the root API only
value = root.call("checksum", "cityhash", None, b"123456789")[0]
nextssl_root_checksum("cityhash", NULL, data, out);
use nextssl_core::Params;
use nextssl_registry::{self as reg, Policy};
let alg = reg::new_checksum_in(reg::all(), Policy::Any, "cityhash", &Params::new())?;
let value = alg.checksum(b"123456789")?;
Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.
Similar names
Looking for something else?More checksums and non-cryptographic hashes
All 130Frequently asked questions
What is Cityhash?
Cityhash is a checksum in the CityHash family. CityHash is a family of non-cryptographic hash functions released by Google in 2011, designed for fast hashing of strings on 64-bit processors.
What are the Cityhash sizes?
In NextSSL, Cityhash uses: output 8 bytes.
Who designed Cityhash and when?
Cityhash belongs to the CityHash family, first published in 2011 by Geoff Pike, Jyrki Alakuijala (Google). Its origin: Google CityHash.
Which standards define Cityhash?
Cityhash is referenced by CityHash64 (Google), NON-cryptographic.
Is Cityhash safe to use?
Cityhash is in the unverified tier. Source found and wired, correctness not fully proven. Root API only. It is only reachable through the root API (NextSSL(root=True) in Python, nextssl_root_* in C).
Related families
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