Class SHA1


  • public final class SHA1
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private byte[] buffer  
      private int buffered  
      private long count  
      private int[] data  
      private static int DATA_LENGTH  
      private int[] digest  
      private static int HASH_LENGTH  
      private byte[] tmp  
      private int[] z  
    • Constructor Summary

      Constructors 
      Constructor Description
      SHA1()
      Constructs a SHA-1 message digest.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static void byte2int​(byte[] src, int srcOffset, int[] dst, int dstOffset, int length)  
      byte[] digest()  
      (package private) byte[] engineDigest()
      Calculates the final digest.
      private byte[] engineDigest​(byte[] in, int pos)
      Returns the digest of all data added (previous and buffered) and resets the digest.
      private void engineReset()
      Initializes (resets) the message digest.
      private void engineTransform​(byte[] in)
      Transform (add) a data block to the message digest.
      (package private) void engineUpdate​(byte b)
      Updates the message digest with a single byte of new data.
      (package private) void engineUpdate​(byte[] data, int offset, int length)
      Updates the message digest with new data.
      private static int f1​(int a, int b, int c)  
      private static int f2​(int a, int b, int c)  
      private static int f3​(int a, int b, int c)  
      private static int f4​(int a, int b, int c)  
      byte[] getSHA1Hash​(byte[] input)
      This method accepts a byte array and returns a SHA-1 secure one-way hash value of it, as a byte array.
      byte[] getSHA1Hash​(java.lang.String str)
      This method accepts a string and returns a SHA-1 secure one-way hash value of that string, as a byte array.
      static byte[] hash​(byte[] input)
      This method accepts a string and returns a SHA-1 secure one-way hash value of that string, as a byte array.
      static byte[] hash​(java.lang.String str)  
      void reset()  
      private void transform​(int[] X)  
      void update​(byte[] input)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • buffer

        private byte[] buffer
      • buffered

        private int buffered
      • count

        private long count
      • digest

        private int[] digest
      • data

        private int[] data
      • z

        private int[] z
      • tmp

        private byte[] tmp
    • Constructor Detail

      • SHA1

        public SHA1()
        Constructs a SHA-1 message digest.
    • Method Detail

      • hash

        public static byte[] hash​(byte[] input)
        This method accepts a string and returns a SHA-1 secure one-way hash value of that string, as a byte array.
      • hash

        public static byte[] hash​(java.lang.String str)
      • getSHA1Hash

        public byte[] getSHA1Hash​(java.lang.String str)
        This method accepts a string and returns a SHA-1 secure one-way hash value of that string, as a byte array.
      • getSHA1Hash

        public byte[] getSHA1Hash​(byte[] input)
        This method accepts a byte array and returns a SHA-1 secure one-way hash value of it, as a byte array.
      • update

        public void update​(byte[] input)
      • reset

        public void reset()
      • digest

        public byte[] digest()
      • engineReset

        private void engineReset()
        Initializes (resets) the message digest.
      • engineUpdate

        void engineUpdate​(byte b)
        Updates the message digest with a single byte of new data.
      • engineUpdate

        void engineUpdate​(byte[] data,
                          int offset,
                          int length)
        Updates the message digest with new data.
        Parameters:
        data - the data to be added.
        offset - the start of the data in the array.
        length - the number of bytes of data to add.
      • engineDigest

        byte[] engineDigest()
        Calculates the final digest.
      • engineDigest

        private byte[] engineDigest​(byte[] in,
                                    int pos)
        Returns the digest of all data added (previous and buffered) and resets the digest.
        Returns:
        the digest of all the data added to the message digest as a byte array.
      • engineTransform

        private void engineTransform​(byte[] in)
        Transform (add) a data block to the message digest.
      • byte2int

        private static void byte2int​(byte[] src,
                                     int srcOffset,
                                     int[] dst,
                                     int dstOffset,
                                     int length)
      • f1

        private static int f1​(int a,
                              int b,
                              int c)
      • f2

        private static int f2​(int a,
                              int b,
                              int c)
      • f3

        private static int f3​(int a,
                              int b,
                              int c)
      • f4

        private static int f4​(int a,
                              int b,
                              int c)
      • transform

        private void transform​(int[] X)