|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--cryptix.MessageDigest
This is the abstract base class for all message digests.
Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/) All rights reserved.
java.crypt.MD5
,
java.crypt.SHA
Constructor Summary | |
protected |
MessageDigest()
Both protected and abstract, so this class must be derived from in order to be useful. |
Method Summary | |
void |
add(byte[] data)
Add a byte array to the digest |
void |
add(byte[] data,
int offset,
int length)
Add a section of a byte array to the digest |
void |
add(java.lang.String message)
Add the low bytes of a string to the digest (ie. |
void |
add(java.lang.String message,
int offset,
int length)
Add the low bytes of a string to the digest (ie. |
protected void |
addToDigest(byte[] data,
int off,
int len)
Add data to the message digest This method is protected to ensure that all parameters are valid at this point - essential if the parameters are passed to native functions. |
long |
bitcount()
Return the number of bits added to the digest so far |
int |
buf_off()
|
byte[] |
buf()
|
abstract int |
data_length()
/** Return the length (in bytes) of the block that this hash function operates on. |
byte[] |
digest()
Obtain the digest |
abstract MessageHash |
digestAsHash()
Obtain the digest as a Hash object |
abstract int |
hash_length()
Return the hash length in bytes |
static byte[] |
hash(byte[] message,
MessageDigest md)
A convenience function for hashing a byte array. |
static byte[] |
hash(java.lang.String message,
MessageDigest md)
A convenience function for hashing a string. |
int |
length()
Return the hash length in bytes |
protected abstract byte[] |
md_digest()
Perform the final transformation |
protected abstract void |
md_reset()
Reset the message digest |
protected abstract void |
md_transform()
Perform a transformation |
abstract java.lang.String |
name()
Return the message digest name |
void |
reset()
Initialise (reset) the message digest. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected MessageDigest()
Method Detail |
public final long bitcount()
public final byte[] buf()
public final int buf_off()
public int length()
public abstract int hash_length()
public abstract int data_length()
public abstract java.lang.String name()
public final void reset()
protected abstract void md_reset()
protected abstract void md_transform()
protected abstract byte[] md_digest()
public final byte[] digest()
N.B. this resets the digest.
public abstract MessageHash digestAsHash()
N.B. this resets the digest.
public final void add(java.lang.String message, int offset, int length)
message
- The string to add.offset
- The start of the data string.length
- The length of the data string.public final void add(java.lang.String message)
message
- The string to add.public final void add(byte[] data)
data
- The data to be added.public final void add(byte[] data, int offset, int length)
data
- The data to add.offset
- The start of the data to add.length
- The length of the data to add.protected final void addToDigest(byte[] data, int off, int len)
data
- The data to be added.off
- The start of the data in the array.len
- The amount of data to add.public static final byte[] hash(java.lang.String message, MessageDigest md)
eg:
byte key[] = MessageDigest.hash( passPhrase, new MD5() );
message
- The string to hash.md
- An instance of a message digest.MD5.hash(java.lang.String)
,
SHA#hash(java.lang.String)
public static final byte[] hash(byte[] message, MessageDigest md)
eg:
byte key[] = MessageDigest.hash( bytearray, new MD5() );
message
- The byte array to hash.md
- An instance of a message digest.MD5.hash(byte[])
,
SHA#hash(byte[])
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |