org.gudy.azureus2.core3.util
Class SHA1

java.lang.Object
  extended by org.gudy.azureus2.core3.util.SHA1

public final class SHA1
extends java.lang.Object

SHA-1 message digest class.


Constructor Summary
SHA1()
          Create a new SHA-1 message digest hasher.
 
Method Summary
 byte[] digest()
          Finishes the SHA-1 message digest calculation.
 byte[] digest(java.nio.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().
 void reset()
          Resets the SHA-1 to initial state for a new message digest calculation.
 void restoreState()
          Restore the digest to its previously-saved state.
 void saveState()
          Save the current digest state.
 void update(java.nio.ByteBuffer buffer)
          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
 

Constructor Detail

SHA1

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

Method Detail

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(java.nio.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(java.nio.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.