|
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 |
digest()
Completes the digest operation. |
byte[] |
digest(byte[] source)
|
byte[] |
digest(byte[] source,
int offset,
int length)
|
boolean |
equals(byte[] otherDigest)
|
boolean |
equals(byte[] otherDigest,
int offset,
int length)
|
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. |
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(String sData)
Deprecated. don't use this method anymore (it's not clean), you might
want to try update(sData.getBytes()) instead |
DIGEST_SIZE
public static final int DIGEST_SIZE
- size of a SHA-1 digest in octets
- See Also:
- Constant Field Values
SHA1
public SHA1()
- Default constructor.
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 addnOfs - the offset of the bytes in the data array.nLen - the number of bytes to add.
update
public void update(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
digest
public byte[] digest(byte[] source,
int offset,
int length)
digest
public byte[] digest(byte[] source)
digest
public void digest()
- Completes the digest operation. You can now fetch the digest using getDigest().
getDigest
public byte[] getDigest()
- Retrieves the digest.
- Returns:
- the digset bytes as an array in DIGEST_SIZE bytes.
equals
public boolean equals(byte[] otherDigest,
int offset,
int length)
equals
public boolean equals(byte[] otherDigest)
getDigest
public int getDigest(byte[] buf,
int nOfs)
- Retrieves the digest into an existing buffer.
- Parameters:
buf - buffer to store the digst intonOfs - where to write to
- Returns:
- number of bytes written
toString
public String toString()
- makes a binhex string representation of the current digest
- Overrides:
toString in class Object
- Returns:
- the string representation