Module hash4j

Interface Hasher128

All Superinterfaces:
Hasher32, Hasher64

public interface Hasher128 extends Hasher64
A 128-bit hash function.

Instances are immutable. Therefore, it is safe to use a single instance across multiple threads and for multiple hash calculations.

Implementations must ensure that

hashTo128Bits(T, com.dynatrace.hash4j.hashing.HashFunnel<T>)(obj, funnel).getAsLong() == Hasher64.hashToLong(T, com.dynatrace.hash4j.hashing.HashFunnel<T>)(obj, funnel)

  • Method Details

    • hashStream

      HashStream128 hashStream()
      Starts a hash stream.
      Specified by:
      hashStream in interface Hasher32
      Specified by:
      hashStream in interface Hasher64
      Returns:
      a new HashStream128 instance
    • hashStreamFromState

      HashStream128 hashStreamFromState(byte[] state)
      Reconstructs a hash stream from a given state.

      The behavior is undefined, if the given state was not created by a hash stream of a hasher that is equal to this hasher.

      Specified by:
      hashStreamFromState in interface Hasher32
      Specified by:
      hashStreamFromState in interface Hasher64
      Returns:
      a new HashStream128 instance
    • hashTo128Bits

      <T> HashValue128 hashTo128Bits(T obj, HashFunnel<T> funnel)
      Hashes an object to a 128-bit HashValue128 value.
      Type Parameters:
      T - the type
      Parameters:
      obj - the object
      funnel - the funnel
      Returns:
      the hash value
    • hashBytesTo128Bits

      HashValue128 hashBytesTo128Bits(byte[] input)
      Hashes a byte array to a 128-bit HashValue128 value.

      Equivalent to hashBytesTo128Bits(input, 0, input.length).

      Parameters:
      input - the byte array
      Returns:
      the hash value
    • hashBytesTo128Bits

      HashValue128 hashBytesTo128Bits(byte[] input, int off, int len)
      Hashes a byte array to a 128-bit HashValue128 value.

      Equivalent to hashTo128Bits(input, (b, f) -> f.putBytes(b, off, len)).

      Parameters:
      input - the byte array
      off - the offset
      len - the length
      Returns:
      the hash value
    • hashBytesTo128Bits

      <T> HashValue128 hashBytesTo128Bits(T input, long off, long len, ByteAccess<T> access)
      Hashes a sequence of bytes to a 128-bit HashValue128 value
      Type Parameters:
      T - the type of the input
      Parameters:
      input - the input
      off - the offset
      len - the length
      access - a strategy to access the bytes of the input
      Returns:
      the hash value
    • hashCharsTo128Bits

      HashValue128 hashCharsTo128Bits(CharSequence input)
      Hashes a CharSequence to a 128-bit HashValue128 value.

      Equivalent to hashTo128Bits(input, (c, f) -> f.putChars(c)).

      Parameters:
      input - the char sequence
      Returns:
      the hash value
    • getHashBitSize

      int getHashBitSize()
      The size of the hash value in bits.
      Returns:
      the size of the hash value in bits