Class java.crypt.MessageDigest
All Packages Class Hierarchy This Package Previous Next Index
Class java.crypt.MessageDigest
java.crypt.MessageDigest
- public class MessageDigest
This is the abstract base class for all message digests.
Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/)
All rights reserved.
- See Also:
- MD5, SHA
-
MessageDigest()
- Both protected and abstract, so this class must be derived
from in order to be useful.
-
add(byte[])
- Add a byte array to the digest
-
add(byte[], int, int)
- Add a section of a byte array to the digest
-
add(String)
- Add the low bytes of a string to the digest (ie.
-
add(String, int, int)
- Add the low bytes of a string to the digest (ie.
-
addToDigest(byte[], int, int)
- Add the data to the hash.
-
digest()
- Obtain the digest
N.B. this resets the digest.
-
digestAsHash()
-
-
hash(byte[], MessageDigest)
- A convenience function for hashing a byte array.
eg:
byte key[] = MessageDigest.hash( bytearray, new MD5() );
-
hash(String, MessageDigest)
- A convenience function for hashing a string.
eg:
byte key[] = MessageDigest.hash( passPhrase, new MD5() );
-
length()
- Return the hash length
N.B. It is advisable to add public static final int HASH_LENGTH
-
reset()
- Initialise (reset) the message digest.
MessageDigest
protected MessageDigest()
- Both protected and abstract, so this class must be derived
from in order to be useful.
length
public abstract int length()
- Return the hash length
N.B. It is advisable to add public static final int HASH_LENGTH
- Returns:
- The length of the hash.
- See Also:
- HASH_LENGTH, HASH_LENGTH
reset
public abstract void reset()
- Initialise (reset) the message digest.
digest
public abstract byte[] digest()
- Obtain the digest
N.B. this resets the digest.
- Returns:
- the digest of all the data added to the message digest.
digestAsHash
public abstract MessageHash digestAsHash()
add
public final void add(String message,
int offset,
int length)
- Add the low bytes of a string to the digest (ie. treat the string as ASCII).
- Parameters:
- message - The string to add.
- offset - The start of the data string.
- length - The length of the data string.
add
public final void add(String message)
- Add the low bytes of a string to the digest (ie. treat the string
as ASCII ).
- Parameters:
- message - The string to add.
add
public final void add(byte data[])
- Add a byte array to the digest
- Parameters:
- data - The data to be added.
add
public final void add(byte data[],
int offset,
int length)
- Add a section of a byte array to the digest
- Parameters:
- data - The data to add.
- offset - The start of the data to add.
- length - The length of the data to add.
addToDigest
protected abstract void addToDigest(byte data[],
int offset,
int length)
- Add the data to the hash.
N.B. the implementor of this function can assume
parameter validation has been done at this point.
- Parameters:
- data - The data to be added. This must remain unmodified.
- offset - The starting point within the array.
- length - The amount of data to add.
hash
public final static byte[] hash(String message,
MessageDigest md)
- A convenience function for hashing a string.
eg:
byte key[] = MessageDigest.hash( passPhrase, new MD5() );
- Parameters:
- message - The string to hash.
- md - An instance of a message digester.
- See Also:
- hash, hash
hash
public final static byte[] hash(byte message[],
MessageDigest md)
- A convenience function for hashing a byte array.
eg:
byte key[] = MessageDigest.hash( bytearray, new MD5() );
- Parameters:
- message - The byte array to hash.
- md - An instance of a message digester.
- See Also:
- hash, hash
All Packages Class Hierarchy This Package Previous Next Index