org.gudy.azureus2.core3.util
Class SHA1Hasher

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

public final class SHA1Hasher
extends Object

SHA-1 hasher utility frontend.


Constructor Summary
SHA1Hasher()
          Create a new SHA1Hasher instance
 
Method Summary
 byte[] calculateHash(byte[] bytes)
          Calculate the SHA-1 hash for the given bytes.
 byte[] calculateHash(ByteBuffer buffer)
          Calculate the SHA-1 hash for the given buffer.
 byte[] getDigest()
          Finish the hash calculation.
 HashWrapper getHash()
           
 void reset()
          Resets the hash calculation.
 void restoreHashState()
          Restore the hasher state from previous save.
 void saveHashState()
          Save the current hasher state for later resuming.
 void update(byte[] data)
          Start or continue a hash calculation with the given data.
 void update(byte[] data, int pos, int len)
          Start or continue a hash calculation with the given data, starting at the given position, for the given length.
 void update(ByteBuffer buffer)
          Start or continue a hash calculation with the given data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SHA1Hasher

public SHA1Hasher()
Create a new SHA1Hasher instance

Method Detail

calculateHash

public byte[] calculateHash(byte[] bytes)
Calculate the SHA-1 hash for the given bytes.

Parameters:
bytes - data to hash
Returns:
20-byte hash

calculateHash

public byte[] calculateHash(ByteBuffer buffer)
Calculate the SHA-1 hash for the given buffer.

Parameters:
buffer - data to hash
Returns:
20-byte hash

update

public void update(byte[] data)
Start or continue a hash calculation with the given data.

Parameters:
data - input

update

public void update(byte[] data,
                   int pos,
                   int len)
Start or continue a hash calculation with the given data, starting at the given position, for the given length.

Parameters:
data - input
pos - start position
len - length

update

public void update(ByteBuffer buffer)
Start or continue a hash calculation with the given data.

Parameters:
buffer - data input

getDigest

public byte[] getDigest()
Finish the hash calculation.

Returns:
20-byte hash

getHash

public HashWrapper getHash()

reset

public void reset()
Resets the hash calculation.


saveHashState

public void saveHashState()
Save the current hasher state for later resuming.


restoreHashState

public void restoreHashState()
Restore the hasher state from previous save.