A Java implementation of Bob Jenkins' hash for non-cryptographic purposes. This implementaion can yield 32-bit and 64-bit hash values and can be used for hashtable lookups.
The algorithm implemented here is ideal for 32-bit architectures.
Jenkins hash is a general purpose hash algorithm created by Bob Jenkins. It takes an input of variable length and processes chunks of 12-bytes each and outputs a hash value as int (32 bits) or long (64 bits).
Advantages over other hash algorithms:
- Uniform distribution of hashes
- Very good avalanche effect
- Faster than most hash algorithms in terms of number of instructions used in hash calculation.
String message = "";
JenkinsHash jh = new JenkinsHash();
int pc = jh.hash32(message.getBytes());
System.out.println(Integer.toHexString(pc));
- Jenkins, Bob (May 2006). The Hash. Retrieved 2011-08-21.