Package com.google.common.hash
Class MessageDigestHashFunction
java.lang.Object
com.google.common.hash.AbstractHashFunction
com.google.common.hash.MessageDigestHashFunction
- All Implemented Interfaces:
HashFunction
,Serializable
HashFunction
adapter for MessageDigest
instances.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Hasher that updates a message digest.private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
private final MessageDigest
private final boolean
private final String
-
Constructor Summary
ConstructorsConstructorDescriptionMessageDigestHashFunction
(String algorithmName, int bytes, String toString) MessageDigestHashFunction
(String algorithmName, String toString) -
Method Summary
Modifier and TypeMethodDescriptionint
bits()
Returns the number of bits (a multiple of 32) that each hash code produced by this hash function has.private static MessageDigest
getMessageDigest
(String algorithmName) Begins a new hash code computation by returning an initialized, statefulHasher
instance that is ready to receive data.private void
readObject
(ObjectInputStream stream) private static boolean
supportsClone
(MessageDigest digest) toString()
(package private) Object
Methods inherited from class com.google.common.hash.AbstractHashFunction
hashBytes, hashBytes, hashBytes, hashInt, hashLong, hashObject, hashString, hashUnencodedChars, newHasher
-
Field Details
-
prototype
-
bytes
private final int bytes -
supportsClone
private final boolean supportsClone -
toString
-
-
Constructor Details
-
MessageDigestHashFunction
-
MessageDigestHashFunction
-
-
Method Details
-
supportsClone
-
bits
public int bits()Description copied from interface:HashFunction
Returns the number of bits (a multiple of 32) that each hash code produced by this hash function has.- Specified by:
bits
in interfaceHashFunction
-
toString
-
getMessageDigest
-
newHasher
Description copied from interface:HashFunction
Begins a new hash code computation by returning an initialized, statefulHasher
instance that is ready to receive data. Example:HashFunction hf = Hashing.md5(); HashCode hc = hf.newHasher() .putLong(id) .putBoolean(isActive) .hash();
- Specified by:
newHasher
in interfaceHashFunction
-
writeReplace
Object writeReplace() -
readObject
- Throws:
InvalidObjectException
-