com.twofivesix
Class JenkinsHash
java.lang.Object
com.twofivesix.JenkinsHash
public class JenkinsHash
- extends java.lang.Object
Hash algorithm by Bob Jenkins, 1996.
You may use this code any way you wish, private, educational, or commercial. It's free.
See: http://burtleburtle.net/bob/hash/doobs.html
Use for hash table lookup, or anything where one collision in 2^^32
is acceptable. Do NOT use for cryptographic purposes.
Java port by Gray Watson http://256stuff.com/gray/
Method Summary |
long |
hash(byte[] buffer)
See hash(byte[] buffer, long initialValue) |
long |
hash(byte[] buffer,
long initialValue)
Hash a variable-length key into a 32-bit value. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JenkinsHash
public JenkinsHash()
hash
public long hash(byte[] buffer,
long initialValue)
- Hash a variable-length key into a 32-bit value. Every bit of the
key affects every bit of the return value. Every 1-bit and 2-bit
delta achieves avalanche. The best hash table sizes are powers of 2.
- Parameters:
buffer
- Byte array that we are hashing on.initialValue
- Initial value of the hash if we are continuing from
a previous run. 0 if none.
- Returns:
- Hash value for the buffer.
hash
public long hash(byte[] buffer)
- See hash(byte[] buffer, long initialValue)
- Parameters:
buffer
- Byte array that we are hashing on.
- Returns:
- Hash value for the buffer.