When you say “hash function” in a room full of developers, people tend to think of the classics: MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA-OHGODPLEASESTOP, and the like — cryptographic hash functions intended for cryptographic uses.
There’s another world out there, though: non-cryptographic hashes. Sometimes you just need to figure out if you’ve already seen a string or structure. Sometimes you need a basic checksum. Sometimes you need a hash that’s just fast and can fit into a 32 bit integer.
I’ll run through the state of the art in the world of non-cryptographic hashing — what your best options are, how they compare in terms of CPU and memory usage, and how they work. Who takes it? Whose mixing function reigns supreme?
Let’s find out.
Adam Harvey is a software developer working on PHP, Go, and C language support at New Relic. Adam has worked on a number of interesting and occasionally even useful things in his two-decade career, including prototyping the worst mesh network of all time (based on Android phones), discovering how to reliably lock up a Windows computer by writing an in-browser video editor, and (most usefully) removing the original mysql_* API from PHP. In his spare time, he contributes to a variety of open source projects, a secret robot project that may have some Asimov-related issues, and a variety of half-finished websites and is attempting to drink every beer Vancouver produces.
©2015, O’Reilly UK Ltd • (800) 889-8969 or (707) 827-7019 • Monday-Friday 7:30am-5pm PT • All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners. • firstname.lastname@example.org