Class SHA1

java.lang.Object
com.ugos.crypt.hash.SHA1

public final class SHA1 extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private byte[]
     
    private int
     
    private long
     
    private int[]
     
    private static final int
     
    private int[]
     
    private static final int
     
    private byte[]
     
    private int[]
     
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    private static void
    byte2int(byte[] src, int srcOffset, int[] dst, int dstOffset, int length)
     
    byte[]
     
    (package private) byte[]
    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
    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[]
    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(String str)
     
    void
     
    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 Details

    • HASH_LENGTH

      private static final int HASH_LENGTH
      See Also:
    • DATA_LENGTH

      private static final int DATA_LENGTH
      See Also:
    • 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 Details

    • SHA1

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

    • 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(String str)
    • getSHA1Hash

      public byte[] getSHA1Hash(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)