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 Summary
Modifier and TypeMethodDescriptionintThe size of the hash value in bits.hashBytesTo128Bits(byte[] input) Hashes a byte array to a 128-bitHashValue128value.hashBytesTo128Bits(byte[] input, int off, int len) Hashes a byte array to a 128-bitHashValue128value.<T> HashValue128hashBytesTo128Bits(T input, long off, long len, ByteAccess<T> access) Hashes a sequence of bytes to a 128-bitHashValue128valuehashCharsTo128Bits(CharSequence input) Hashes aCharSequenceto a 128-bitHashValue128value.Starts a hash stream.hashStreamFromState(byte[] state) Reconstructs a hash stream from a given state.<T> HashValue128hashTo128Bits(T obj, HashFunnel<T> funnel) Hashes an object to a 128-bitHashValue128value.Methods inherited from interface com.dynatrace.hash4j.hashing.Hasher32
hashBytesToInt, hashBytesToInt, hashBytesToInt, hashCharsToInt, hashIntIntIntToInt, hashIntIntToInt, hashIntLongToInt, hashIntToInt, hashLongIntToInt, hashLongLongLongToInt, hashLongLongToInt, hashLongToInt, hashToIntMethods inherited from interface com.dynatrace.hash4j.hashing.Hasher64
hashBytesToLong, hashBytesToLong, hashBytesToLong, hashCharsToLong, hashIntIntIntToLong, hashIntIntToLong, hashIntLongToLong, hashIntToLong, hashLongIntToLong, hashLongLongLongToLong, hashLongLongToLong, hashLongToLong, hashToLong
-
Method Details
-
hashStream
HashStream128 hashStream()Starts a hash stream.- Specified by:
hashStreamin interfaceHasher32- Specified by:
hashStreamin interfaceHasher64- Returns:
- a new
HashStream128instance
-
hashStreamFromState
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:
hashStreamFromStatein interfaceHasher32- Specified by:
hashStreamFromStatein interfaceHasher64- Returns:
- a new
HashStream128instance
-
hashTo128Bits
Hashes an object to a 128-bitHashValue128value.- Type Parameters:
T- the type- Parameters:
obj- the objectfunnel- the funnel- Returns:
- the hash value
-
hashBytesTo128Bits
Hashes a byte array to a 128-bitHashValue128value.Equivalent to
hashBytesTo128Bits(input, 0, input.length).- Parameters:
input- the byte array- Returns:
- the hash value
-
hashBytesTo128Bits
Hashes a byte array to a 128-bitHashValue128value.Equivalent to
hashTo128Bits(input, (b, f) -> f.putBytes(b, off, len)).- Parameters:
input- the byte arrayoff- the offsetlen- the length- Returns:
- the hash value
-
hashBytesTo128Bits
Hashes a sequence of bytes to a 128-bitHashValue128value- Type Parameters:
T- the type of the input- Parameters:
input- the inputoff- the offsetlen- the lengthaccess- a strategy to access the bytes of the input- Returns:
- the hash value
-
hashCharsTo128Bits
Hashes aCharSequenceto a 128-bitHashValue128value.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
-