FileDocCategorySizeDatePackage
SHA1Hasher.javaAPI DocAzureus 3.0.3.42919Sat Sep 08 14:21:44 BST 2007org.gudy.azureus2.core3.util

SHA1Hasher

public final class SHA1Hasher extends Object
SHA-1 hasher utility frontend.

Fields Summary
private final SHA1
sha1
Constructors Summary
public SHA1Hasher()
Create a new SHA1Hasher instance

    sha1 = new SHA1();
  
Methods Summary
public byte[]calculateHash(byte[] bytes)
Calculate the SHA-1 hash for the given bytes.

param
bytes data to hash
return
20-byte hash

    ByteBuffer buff = ByteBuffer.wrap( bytes );
    return calculateHash( buff );
  
public byte[]calculateHash(java.nio.ByteBuffer buffer)
Calculate the SHA-1 hash for the given buffer.

param
buffer data to hash
return
20-byte hash

    sha1.reset();
    return sha1.digest( buffer );
  
public byte[]getDigest()
Finish the hash calculation.

return
20-byte hash

  	return sha1.digest();
  
public voidreset()
Resets the hash calculation.

    sha1.reset();
  
public voidrestoreHashState()
Restore the hasher state from previous save.

    sha1.restoreState();
  
public voidsaveHashState()
Save the current hasher state for later resuming.

    sha1.saveState();
  
public voidupdate(byte[] data)
Start or continue a hash calculation with the given data.

param
data input

  	update( ByteBuffer.wrap( data ));
  
public voidupdate(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.

param
data input
param
pos start position
param
len length

  	update( ByteBuffer.wrap( data, pos, len ));
  
public voidupdate(java.nio.ByteBuffer buffer)
Start or continue a hash calculation with the given data.

param
buffer data input

    sha1.update( buffer );