While hashing methods such as MD5 and SHA-1 use cryto methods, the Murmur and FNV hashes uses a non-cryptographic hash function. The Murmur hash, designed by Austin Appleby, uses a non-cryptographic hash function. This can be used for general hash-based lookups. It has a good performance compared with other hashing methods, and generally provide a good balance between performance and CPU utilization. Also it performs well in terms of hash collisions. [Theory]
Murmur hash |
Outline
The following provides a diagram of the method (taken from [1]):
Test Vector
A sample vector is:
Input "The quick brown fox jumps over the lazy dog" 128-bit should give "6c1b07bc7bbc4be347939ac4a93c437a"
Coding
An example of the coding is:
import smhasher import sys msg="The quick brown fox jumps over the lazy dog" print ('Message is:',msg) res=smhasher.murmur3_x64_128(msg,0) print('Murmur (x64 128-bit):\n%d\n %s\n' % (res, hex(res))) res=smhasher.murmur3_x64_64(msg,0) print('Murmur (x64 64-bit):\n%d\n %s\n' % (res, hex(res))) res=smhasher.murmur3_x86_64(msg,0) print('Murmur (x86 128-bit):\n%d\n %s\n' % (res, hex(res))) res=smhasher.murmur3_x86_128(msg,0) print('Murmur (x86 64-bit):\n%d\n %s\n' % (res, hex(res)))
[1] http://stackoverflow.com/questions/1057036/please-explain-murmur-hash