Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.ssttr.crypto
Class MessageDigest  view MessageDigest download MessageDigest.java

java.lang.Object
  extended bycom.ssttr.crypto.MessageDigest
Direct Known Subclasses:
MD2, MD5, SHA1

public abstract class MessageDigest
extends java.lang.Object

The MessageDigest class defines a general class for computing digest functions. It is defined as an abstract class that is subclassed by message digest algorithms. In this way the PKCS classes can be built to take a MessageDigest object without needing to know what 'kind' of message digest they are computing. This class defines the standard functions that all message digest algorithms share, and ways to put all Java fundamental types into the digest. It does not define methods for digestifying either arbitrary objects or arrays of objects however.

Version:
5 Oct 1996, 1.8

Field Summary
 byte[] digestBits
          the actual digest bits.
 boolean digestValid
          status of the digest
(package private) static byte[] testdata
           
 
Constructor Summary
MessageDigest()
           
 
Method Summary
static void benchmark(MessageDigest md)
           
 void computeDigest(byte[] source)
          Complete digest computation on an array of bytes.
 void computeDigest(java.io.InputStream in)
           
abstract  void finish()
          Perform the final computations and cleanup.
abstract  java.lang.String getAlg()
          Return a string that represents the algorithim of this message digest.
 java.lang.String getDigest()
           
 byte[] getDigestBytes()
           
 java.lang.String getDigestHex()
           
private  void hexDigit(java.io.PrintStream p, byte x)
          helper function that prints unsigned two character hex digits.
abstract  void init()
          This function is used to initialize any internal digest variables or parameters.
 boolean isEqual(byte[] otherDigest)
          Non static version that compares this digest to one passed.
static boolean isEqual(byte[] digesta, byte[] digestb)
          Compare two digests for equality.
 java.lang.String toString()
          Return a string representation of this object.
 void update(boolean aValue)
          Add a boolean to the digest.
abstract  void update(byte aValue)
          The basic unit of digestifying is the byte.
 void update(byte[] input)
          Add an array of bytes to the digest.
 void update(byte[] input, int offset, int len)
          Add specific bytes to the digest.
 void update(java.io.InputStream in)
          Read a stream and update a digest until the stream sends an EOF.
 void update(int aValue)
          Add an integer value to the digest.
 void update(int[] input)
          Add an array of integers to the digest.
 void update(long aValue)
          Add a long to the digest.
 void update(long[] input)
          Add an array of longs to the digest.
 void update(short aValue)
          Add a short value to the digest.
 void update(short[] input)
          Add an array of shorts to the digest.
 void update(java.lang.String input)
          Add the bytes in the String 'input' to the current digest.
 void updateASCII(java.lang.String input)
          Treat the string as a sequence of ISO-Latin1 (8 bit) characters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

digestBits

public byte[] digestBits
the actual digest bits.


digestValid

public boolean digestValid
status of the digest


testdata

static byte[] testdata
Constructor Detail

MessageDigest

public MessageDigest()
Method Detail

init

public abstract void init()
This function is used to initialize any internal digest variables or parameters.


update

public abstract void update(byte aValue)
The basic unit of digestifying is the byte. This method is defined by the particular algorithim's subclass for that algorithim. Subsequent versions of this method defined here decompose the basic type into bytes and call this function. If special processing is needed for a particular type your subclass should override the method for that type.


update

public void update(boolean aValue)
Add a boolean to the digest.


update

public void update(short aValue)
Add a short value to the digest.


update

public void update(int aValue)
Add an integer value to the digest.


update

public void update(long aValue)
Add a long to the digest.


update

public void update(byte[] input,
                   int offset,
                   int len)
Add specific bytes to the digest.


update

public void update(byte[] input)
Add an array of bytes to the digest.


update

public void update(short[] input)
Add an array of shorts to the digest.


update

public void update(int[] input)
Add an array of integers to the digest.


update

public void update(long[] input)
Add an array of longs to the digest.


update

public void update(java.lang.String input)
Add the bytes in the String 'input' to the current digest. Note that the string characters are treated as unicode chars of 16 bits each. To digestify ISO-Latin1 strings (ASCII) use the updateASCII() method.


updateASCII

public void updateASCII(java.lang.String input)
Treat the string as a sequence of ISO-Latin1 (8 bit) characters.


update

public void update(java.io.InputStream in)
Read a stream and update a digest until the stream sends an EOF.


finish

public abstract void finish()
Perform the final computations and cleanup.


computeDigest

public void computeDigest(byte[] source)
Complete digest computation on an array of bytes.


computeDigest

public void computeDigest(java.io.InputStream in)

hexDigit

private void hexDigit(java.io.PrintStream p,
                      byte x)
helper function that prints unsigned two character hex digits.


toString

public java.lang.String toString()
Return a string representation of this object.


getDigest

public java.lang.String getDigest()

getDigestBytes

public byte[] getDigestBytes()

getDigestHex

public java.lang.String getDigestHex()

isEqual

public static boolean isEqual(byte[] digesta,
                              byte[] digestb)
Compare two digests for equality. Simple byte compare.


isEqual

public boolean isEqual(byte[] otherDigest)
Non static version that compares this digest to one passed.


getAlg

public abstract java.lang.String getAlg()
Return a string that represents the algorithim of this message digest.


benchmark

public static void benchmark(MessageDigest md)