Module notzed.dez
Package au.notzed.dez

Class 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

      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CyclicHash

        public CyclicHash​(int length)
        Creates a cyclic hash.
        length - The block length for the hash.
    • Method Detail

      • init

        public int init​(byte[] data,
                        int off)
        Initialises the hash.

        This will hash one block of data at the given location.

        data - Data buffer.
        off - Offset into data.
        The hash code of this block.
        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.

        leave - the byte leaving. Must match the oldest byte included in the hash value.
        enter - the byte entering.
        The hash code for the last block-size bytes.