Class java.crypt.MessageDigest
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.crypt.MessageDigest

java.lang.Object
   |
   +----java.crypt.MessageDigest

public class MessageDigest
extends Object
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

Constructor Index

 o MessageDigest()
Both protected and abstract, so this class must be derived from in order to be useful.

Method Index

 o add(String, int, int)
Add the low bytes of a string to the digest (ie.
 o add(String)
Add the low bytes of a string to the digest (ie.
 o add(byte[])
Add a byte array to the digest
 o add(byte[], int, int)
Add a section of a byte array to the digest
 o addToDigest(byte[], int, int)
Add the data to the hash.
 o digest()
Obtain the digest

N.B. this resets the digest.

 o hash(String, MessageDigest)
A convenience function for hashing a string.

eg:

 byte key[] = MessageDigest.hash( passPhrase, new MD5() ); 
 o length()
Return the hash length

N.B. It is advisable to add public static final int HASH_LENGTH

 o reset()
Initialise (reset) the message digest.

Constructors

 o MessageDigest
  protected MessageDigest()
Both protected and abstract, so this class must be derived from in order to be useful.

Methods

 o 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
 o reset
  public abstract void reset()
Initialise (reset) the message digest.
 o 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.
 o 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.
 o 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.
 o add
  public final void add(byte data[])
Add a byte array to the digest
Parameters:
data - The data to be added.
 o 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.
 o 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.
 o 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.

All Packages  Class Hierarchy  This Package  Previous  Next  Index