Class SHA1

java.lang.Object
com.biglybt.core.util.SHA1

public final class SHA1 extends Object
SHA-1 message digest class.
  • Field Summary

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

    Constructors
    Constructor
    Description
    Create a new SHA-1 message digest hasher.
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
     
    byte[]
    Finishes the SHA-1 message digest calculation.
    byte[]
    Finishes the SHA-1 message digest calculation, by first performing a final update from the given input buffer, then completing the calculation as with digest().
    static void
    main(String[] args)
     
    void
    Resets the SHA-1 to initial state for a new message digest calculation.
    void
    Restore the digest to its previously-saved state.
    void
    Save the current digest state.
    private void
    transform(byte[] ar, int offset)
     
    void
    Starts or continues a SHA-1 message digest calculation.

    Methods inherited from class java.lang.Object

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

    • h0

      private int h0
    • h1

      private int h1
    • h2

      private int h2
    • h3

      private int h3
    • h4

      private int h4
    • finalBuffer

      private final ByteBuffer finalBuffer
    • saveBuffer

      private final ByteBuffer saveBuffer
    • s0

      private int s0
    • s1

      private int s1
    • s2

      private int s2
    • s3

      private int s3
    • s4

      private int s4
    • length

      private long length
    • saveLength

      private long saveLength
    • cacheSize

      private static final int cacheSize
      See Also:
    • cacheBlock

      private byte[] cacheBlock
  • Constructor Details

    • SHA1

      public SHA1()
      Create a new SHA-1 message digest hasher.
  • Method Details

    • transform

      private void transform(byte[] ar, int offset)
    • completeFinalBuffer

      private void completeFinalBuffer(ByteBuffer buffer)
    • reset

      public void reset()
      Resets the SHA-1 to initial state for a new message digest calculation. Must be called before starting a new hash calculation.
    • update

      public void update(ByteBuffer buffer)
      Starts or continues a SHA-1 message digest calculation. Only the remaining bytes of the given ByteBuffer are used.
      Parameters:
      buffer - input data
    • digest

      public byte[] digest()
      Finishes the SHA-1 message digest calculation.
      Returns:
      20-byte hash result
    • digest

      public byte[] digest(ByteBuffer buffer)
      Finishes the SHA-1 message digest calculation, by first performing a final update from the given input buffer, then completing the calculation as with digest().
      Parameters:
      buffer - input data
      Returns:
      20-byte hash result
    • saveState

      public void saveState()
      Save the current digest state. This allows the resuming of a SHA-1 calculation, even after a digest calculation is finished with digest().
    • restoreState

      public void restoreState()
      Restore the digest to its previously-saved state.
    • main

      public static void main(String[] args)