net.sourceforge.blowfishj
Class SHA1

java.lang.Object
  extended bynet.sourceforge.blowfishj.SHA1

public class SHA1
extends java.lang.Object

SHA-1 message digest implementation, translated from C source code (the origin is unknown).


Field Summary
static int DIGEST_SIZE
          size of a SHA-1 digest in octets
 
Constructor Summary
SHA1()
          Default constructor.
 
Method Summary
 void clear()
          Clears all data, use reset() to start again.
 void finalize()
          Finalizes the digest.
 byte[] getDigest()
          Retrieves the digest.
 int getDigest(byte[] buf, int nOfs)
          Retrieves the digest into an existing buffer.
 void reset()
          Initializes (or resets) the hasher for a new session.
 boolean selfTest()
          Runs an integrity test.
 java.lang.String toString()
          makes a binhex string representation of the current digest
 void update(byte bB)
          Adds a single byte to the digest.
 void update(byte[] data)
          Deprecated. use update(byte[], int, int) instead
 void update(byte[] data, int nOfs, int nLen)
          Adds a portion of a byte array to the digest.
 void update(java.lang.String sData)
          Deprecated. don't use this method anymore (it's not clean), you might want to try update(sData.getBytes()) instead
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DIGEST_SIZE

public static final int DIGEST_SIZE
size of a SHA-1 digest in octets

See Also:
Constant Field Values
Constructor Detail

SHA1

public SHA1()
Default constructor.

Method Detail

clear

public void clear()
Clears all data, use reset() to start again.


reset

public void reset()
Initializes (or resets) the hasher for a new session.


update

public void update(byte bB)
Adds a single byte to the digest.

Parameters:
bB - the byte to add

update

public void update(byte[] data)
Deprecated. use update(byte[], int, int) instead

Adds a byte array to the digest.

Parameters:
data - the data to add

update

public void update(byte[] data,
                   int nOfs,
                   int nLen)
Adds a portion of a byte array to the digest.

Parameters:
data - the data to add

update

public void update(java.lang.String sData)
Deprecated. don't use this method anymore (it's not clean), you might want to try update(sData.getBytes()) instead

Adds an ASCII string (8bit) to the digest.

Parameters:
sData - the string to add

finalize

public void finalize()
Finalizes the digest.


getDigest

public byte[] getDigest()
Retrieves the digest.

Returns:
the digst bytes as an array if DIGEST_SIZE bytes

getDigest

public int getDigest(byte[] buf,
                     int nOfs)
Retrieves the digest into an existing buffer.

Parameters:
buf - buffer to store the digst into
nOfs - where to write to
Returns:
number of bytes written

toString

public java.lang.String toString()
makes a binhex string representation of the current digest

Returns:
the string representation

selfTest

public boolean selfTest()
Runs an integrity test.

Returns:
true: selftest passed / false: selftest failed


Copyright © 2004-2005 Sourceforge. All Rights Reserved.