Class Digest

  • Direct Known Subclasses:
    MD5Digest, SHA1Digest, SHA256Digest

    public abstract class Digest
    extends java.lang.Object
    This class provides the functionality of a message digest algorithm.
    • Constructor Summary

      Constructors 
      Constructor Description
      Digest()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract java.lang.String getAlgorithm()
      Returns the name of the algorithm.
      abstract int getBlockLength()
      Returns the block length.
      byte[] getDigest()
      Finalizes the message digest operation by processing all the accumulated input data and returning the result in a new buffer.
      abstract int getDigestLength()
      Returns the message digest length.
      protected abstract byte[] process​(byte[] data)  
      void reset()
      Initializes this message digest.
      java.lang.String toString()
      Returns the name of the algorithm.
      void update​(byte[] data)
      Updates the input data that will be processed by this message digest algorithm.
      void update​(byte[] data, int start, int count)
      Updates the input data that will be processed by this message digest algorithm.
      void update​(int data)
      Updates the input data that will be processed by this message digest algorithm.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Digest

        public Digest()
    • Method Detail

      • toString

        public java.lang.String toString()
        Returns the name of the algorithm.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The name of the algorithm whose class heirs from Digest.
      • getAlgorithm

        public abstract java.lang.String getAlgorithm()
        Returns the name of the algorithm.
        Returns:
        The name of the algorithm whose class heirs from Digest.
      • getBlockLength

        public abstract int getBlockLength()
        Returns the block length.
        Returns:
        The block length (in bytes).
      • getDigestLength

        public abstract int getDigestLength()
        Returns the message digest length.
        Returns:
        The message digest length (in bytes).
      • reset

        public final void reset()
        Initializes this message digest. Calling this method will also reset the input data buffer.
      • update

        public final void update​(int data)
        Updates the input data that will be processed by this message digest algorithm. The data will be accumulated in an input buffer to be processed when getDigest() is finally called.
        Parameters:
        data - The input data.
      • update

        public final void update​(byte[] data)
        Updates the input data that will be processed by this message digest algorithm. The data will be accumulated in an input buffer to be processed when getDigest() is finally called.
        Parameters:
        data - The input data.
      • update

        public final void update​(byte[] data,
                                 int start,
                                 int count)
        Updates the input data that will be processed by this message digest algorithm. The data will be accumulated in an input buffer to be processed when getDigest() is finally called.
        Parameters:
        data - The input data.
        start - The offset in data where the data starts.
        count - The input length.
      • getDigest

        public final byte[] getDigest()
        Finalizes the message digest operation by processing all the accumulated input data and returning the result in a new buffer.
        Returns:
        The operation result in a new buffer.
      • process

        protected abstract byte[] process​(byte[] data)