Class cryptix.security.MessageDigest
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class cryptix.security.MessageDigest

java.lang.Object
   |
   +----cryptix.security.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(byte[])
Add a byte array to the digest
 o add(byte[], int, int)
Add a section of a byte array to the digest
 o add(String)
Add the low bytes of a string to the digest (ie.
 o add(String, int, int)
Add the low bytes of a string to the digest (ie.
 o addToDigest(byte[], int, int)
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.
 o bitcount()
Return the number of bits added to the digest so far
 o buf()
 o buf_off()
 o data_length()
/** Return the length (in bytes) of the block that this hash function operates on.
 o digest()
Obtain the digest

N.B.

 o digestAsHash()
Obtain the digest as a Hash object

N.B.

 o hash(byte[], MessageDigest)
A convenience function for hashing a byte array.

eg:

 byte key[] = MessageDigest.hash( bytearray, new MD5() ); 
 o hash(String, MessageDigest)
A convenience function for hashing a string.

eg:

 byte key[] = MessageDigest.hash( passPhrase, new MD5() ); 
 o hash_length()
Return the hash length in bytes
 o length()
Return the hash length in bytes
 o md_digest()
Perform the final transformation
 o md_reset()
Reset the message digest
 o md_transform()
Perform a transformation
 o name()
Return the message digest name
 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 bitcount
  public final long bitcount()
Return the number of bits added to the digest so far
 o buf
  public final byte[] buf()
 o buf_off
  public final int buf_off()
 o length
  public int length()
Return the hash length in bytes
 o hash_length
  public abstract int hash_length()
Return the hash length in bytes
 o data_length
  public abstract int data_length()
/** Return the length (in bytes) of the block that this hash function operates on.
 o name
  public abstract String name()
Return the message digest name
Returns:
The name of the message digest.
 o reset
  public final void reset()
Initialise (reset) the message digest.
 o md_reset
  protected abstract void md_reset()
Reset the message digest
 o md_transform
  protected abstract void md_transform()
Perform a transformation
 o md_digest
  protected abstract byte[] md_digest()
Perform the final transformation
 o digest
  public final byte[] digest()
Obtain the digest

N.B. this resets the digest.

Returns:
the digest of all the data added to the message digest.
 o digestAsHash
  public abstract MessageHash digestAsHash()
Obtain the digest as a Hash object

N.B. this resets the digest.

Returns:
the Hash 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 final 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.
Parameters:
data - The data to be added.
off - The start of the data in the array.
len - 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 digest.
See Also:
hash, hash
 o 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 digest.
See Also:
hash, hash

All Packages  Class Hierarchy  This Package  Previous  Next  Index