Skip to content

vkandy/jenkins-hash-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Jenkins Hash

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.

What is Jenkins hash?

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:

  1. Uniform distribution of hashes
  2. Very good avalanche effect
  3. Faster than most hash algorithms in terms of number of instructions used in hash calculation.

Usage

String message = "";
JenkinsHash jh = new JenkinsHash();
int pc = jh.hash32(message.getBytes());

System.out.println(Integer.toHexString(pc));

References

  • Jenkins, Bob (May 2006). The Hash. Retrieved 2011-08-21.

About

Jenkins' hash which yields 32-bit and 64-bit values

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages