Class MessageDigestHashFunction

java.lang.Object
com.google.common.hash.AbstractHashFunction
com.google.common.hash.MessageDigestHashFunction
All Implemented Interfaces:
HashFunction, Serializable

final class MessageDigestHashFunction extends AbstractHashFunction implements Serializable
HashFunction adapter for MessageDigest instances.
  • Field Details

    • prototype

      private final MessageDigest prototype
    • bytes

      private final int bytes
    • supportsClone

      private final boolean supportsClone
    • toString

      private final String toString
  • Constructor Details

    • MessageDigestHashFunction

      MessageDigestHashFunction(String algorithmName, String toString)
    • MessageDigestHashFunction

      MessageDigestHashFunction(String algorithmName, int bytes, String toString)
  • Method Details

    • supportsClone

      private static boolean supportsClone(MessageDigest digest)
    • 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 interface HashFunction
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getMessageDigest

      private static MessageDigest getMessageDigest(String algorithmName)
    • newHasher

      public Hasher newHasher()
      Description copied from interface: HashFunction
      Begins a new hash code computation by returning an initialized, stateful Hasher 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 interface HashFunction
    • writeReplace

      Object writeReplace()
    • readObject

      private void readObject(ObjectInputStream stream) throws InvalidObjectException
      Throws:
      InvalidObjectException