Hash Functions
Bad Hash Functions
- First 3 digits of a phone number
- Memory address of an object (will only be power of 2's so odd locations will never get filled)
MurmurHash / MurmurHash3
MurmurHashis a non-cryptographichash function suitable for general hash-based lookup.It was created by Austin Appleby in 2008and is currently hosted on GitHub along with its test suite named 'SMHasher'. It also exists in a number of variants,all of which have been released into the public domain. The name comes from two basic operations, multiply (MU) and rotate (R), used in its inner loop.
Unlike cryptographic hash functions, it is not specifically designed to be difficult to reverse by an adversary, making it unsuitable for cryptographic purposes.
https://en.wikipedia.org/wiki/MurmurHash
SipHash (for strings in python dictionary implementation)
SipHash is a relatively fast hash function. On a 64-bit machine, SipHash returns a 64-bit hash. The hash is then converted into an index to be used in an array.
SipHash is an add--rotate--xor(ARX) based family of pseudorandom functions created by Jean-Philippe Aumasson and Daniel J. Bernstein in 2012, in response to a spate of "hash flooding"denial-of-service attacks in late 2011.
Although designed for use as a hash function in the computer science sense, SipHash is fundamentally different from cryptographic hash functions like SHA in that it is only suitable as a message authentication code: akeyedhash function like HMAC. That is, SHA is designed so that it is difficult for an attacker to find two messages X and Y such that SHA(X) = SHA(Y)
, even though anyone may compute SHA(X). SipHash instead guarantees that, having seenXiand SipHash(Xi,k)
, an attacker who does not know the keykcannot find (any information about) kor SipHash(Y,k)
for any message Y∉ {Xi}
which they have not seen before.