FNV hash
The Fowler–Noll–Vo hash: a minimal multiply-and-XOR function for hash tables
Overview
FNV is a non-cryptographic hash function created by Glenn Fowler, Landon Curt Noll and Kiem-Phong Vo. Its simplicity, a single multiply and XOR per byte, made it popular in compilers, DNS servers and hash tables. It provides no security against a deliberate attacker.
FNV starts from a fixed offset basis and, for each input byte, either multiplies the hash by a large FNV prime and then XORs the byte (FNV-1) or XORs first and then multiplies (FNV-1a). FNV-1a has slightly better avalanche behaviour. Primes and offset bases are defined for widths from 32 to 1024 bits.
NextSSL includes the 64-bit FNV-1 and FNV-1a, as described in draft-eastlake-fnv, wired from source and not yet verified. Its simplicity makes it easy to embed and reimplement. None of this provides security: the function has no secret key, and anyone can compute or deliberately collide its outputs. Use SipHash instead.
History
1991–1991FNV hash published by Glenn Fowler, Landon Curt Noll, Kiem-Phong Vo
Security notes
FNV is not cryptographic. Collisions are easy to construct and it has no key or seed, so it is vulnerable to hash flooding when inputs are adversarial.
Typical uses
Variants in NextSSL
2Frequently asked questions
Which FNV hash variants does NextSSL include?
NextSSL registers 2 FNV hash variants: fnv-1, fnv-1a.