Class JavaCrc32

All Implemented Interfaces:
Hash, StatefulHash, StatefulIntHash

final class JavaCrc32 extends AbstractStatefulHash implements StatefulIntHash
  • Constructor Details

    • JavaCrc32

      JavaCrc32()
  • Method Details

    • algorithm

      public String algorithm()
      Description copied from interface: Hash
      Returns the canonical name of this hash algorithm.
      Specified by:
      algorithm in interface Hash
      Returns:
      the name of this hash algorithm
    • length

      public int length()
      Description copied from interface: Hash
      Returns the length in bytes of the output of this hash function.
      Specified by:
      length in interface Hash
      Returns:
      the hash length in bytes
    • createNew

      public StatefulHash createNew()
      Description copied from interface: StatefulHash
      Returns a new instance of this stateful hash function reset to the initial state.
      Specified by:
      createNew in interface StatefulHash
      Returns:
      a new instance of this hash in the initial state
    • supportsIncremental

      public boolean supportsIncremental()
      Description copied from interface: StatefulHash
      Returns whether this hash function supports incremental hashing. Incremental hashing allows calling the StatefulHash.update(byte[]) methods to continue hashing using accumulated state after calling any of the output methods (such as StatefulHash.getBytes()). Non-incremental hash functions require calling StatefulHash.reset() to reinitialize the state between calling an output method and an update method.
      Specified by:
      supportsIncremental in interface StatefulHash
      Returns:
      true if incremental hashing is supported, false if not
    • reset

      public void reset()
      Description copied from interface: StatefulHash
      Resets this hash function to its initial state. Resetting the state is required for non-incremental hash functions after any output methods have been called.
      Specified by:
      reset in interface StatefulHash
    • updateUnchecked

      protected void updateUnchecked(byte[] input, int index, int length)
      Description copied from class: AbstractStatefulHash
      Updates the state of this hash function with the given range of the given input array. The index and length parameters have already been validated.
      Specified by:
      updateUnchecked in class AbstractStatefulHash
      Parameters:
      input - the input array
      index - the starting index of the first input byte
      length - the length of the input range
    • getInt

      public int getInt()
      Description copied from interface: StatefulHash
      Returns the first four bytes of the output of this hash function as a little-endian int. If the output is less than four bytes, the remaining bytes are set to 0.
      Specified by:
      getInt in interface StatefulHash
      Returns:
      the first four output bytes as an int
    • getLong

      public long getLong()
      Description copied from interface: StatefulHash
      Returns the first eight bytes of the output of this hash function as a little-endian long. If the output is less than eight bytes, the remaining bytes are set to 0.
      Specified by:
      getLong in interface StatefulHash
      Returns:
      the first eight output bytes as a long
    • asStateless

      public StatelessIntHash asStateless()
      Description copied from interface: StatefulIntHash
      Returns an instance of stateless version of this hash function.
      Specified by:
      asStateless in interface StatefulIntHash
      Returns:
      the stateless version of this hash function