- java.lang.Object
-
- au.notzed.dez.CyclicHash
-
public class CyclicHash extends java.lang.Object
Cyclic polynomial rolling hash.This implements a rolling hash of a fixed length.
Input bytes are hashed using a random table. The randomness affects the quality of the hash.
-
-
Constructor Summary
Constructors Constructor Description CyclicHash(int length)
Creates a cyclic hash.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
init(byte[] data, int off)
Initialises the hash.int
update(byte leave, byte enter)
Updates the hash incrementally.
-
-
-
Method Detail
-
init
public int init(byte[] data, int off)
Initialises the hash.This will hash one block of data at the given location.
- Parameters:
data
- Data buffer.off
- Offset into data.- Returns:
- The hash code of this block.
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- If the buffer is too short.
-
update
public int update(byte leave, byte enter)
Updates the hash incrementally.Advance the hash by one location.
- Parameters:
leave
- the byte leaving. Must match the oldest byte included in the hash value.enter
- the byte entering.- Returns:
- The hash code for the last block-size bytes.
-
-