Class SHA

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class SHA
    extends java.security.MessageDigestSpi
    implements java.lang.Cloneable
    This class implements the Secure Hash Algorithm (SHA) developed by the National Institute of Standards and Technology along with the National Security Agency. This is the updated version of SHA fip-180 as superseded by fip-180-1.

    It implement JavaSecurity MessageDigest, and can be used by in the Java Security framework, as a pluggable implementation, as a filter for the digest stream classes.

    Version:
    1.30 97/12/10
    Author:
    Roger Riggs, Benjamin Renaud
    • Constructor Summary

      Constructors 
      Constructor Description
      SHA()
      Creates a new SHA object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()  
      byte[] engineDigest()
      Computes the final hash and returns the final value as a byte[20] array.
      int engineDigest​(byte[] hashvalue, int offset, int len)
      Computes the final hash and returns the final value as a byte[20] array.
      protected int engineGetDigestLength()
      Return the length of the digest in bytes
      void engineReset()
      Resets the buffers and hash value to start a new hash.
      void engineUpdate​(byte b)  
      void engineUpdate​(byte[] b, int off, int len)
      Update a buffer.
      void init()
      Resets the buffers and hash value to start a new hash.
      • Methods inherited from class java.security.MessageDigestSpi

        engineUpdate
      • Methods inherited from class java.lang.Object

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

      • SHA

        public SHA()
        Creates a new SHA object.
    • Method Detail

      • engineGetDigestLength

        protected int engineGetDigestLength()
        Return the length of the digest in bytes
        Overrides:
        engineGetDigestLength in class java.security.MessageDigestSpi
      • engineUpdate

        public void engineUpdate​(byte b)
        Specified by:
        engineUpdate in class java.security.MessageDigestSpi
      • engineUpdate

        public void engineUpdate​(byte[] b,
                                 int off,
                                 int len)
        Update a buffer.
        Specified by:
        engineUpdate in class java.security.MessageDigestSpi
        Parameters:
        b - the data to be updated.
        off - the start offset in the data
        len - the number of bytes to be updated.
      • init

        public void init()
        Resets the buffers and hash value to start a new hash.
      • engineReset

        public void engineReset()
        Resets the buffers and hash value to start a new hash.
        Specified by:
        engineReset in class java.security.MessageDigestSpi
      • engineDigest

        public byte[] engineDigest()
        Computes the final hash and returns the final value as a byte[20] array. The object is reset to be ready for further use, as specified in the JavaSecurity MessageDigest specification.
        Specified by:
        engineDigest in class java.security.MessageDigestSpi
      • engineDigest

        public int engineDigest​(byte[] hashvalue,
                                int offset,
                                int len)
                         throws java.security.DigestException
        Computes the final hash and returns the final value as a byte[20] array. The object is reset to be ready for further use, as specified in the JavaSecurity MessageDigest specification.
        Overrides:
        engineDigest in class java.security.MessageDigestSpi
        Throws:
        java.security.DigestException
      • clone

        public java.lang.Object clone()
        Overrides:
        clone in class java.security.MessageDigestSpi