cryptix.security
Class MessageDigestOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended bycryptix.security.MessageDigestOutputStream
Direct Known Subclasses:
MD5OutputStream, SHAOutputStream

public class MessageDigestOutputStream
extends java.io.OutputStream

This class is an output stream that hashes the data sent to it using the message digest that it has been constructed with.

References

Copyright © 1995-1997 Systemics Ltd on behalf of the Cryptix Development Team. All rights reserved.

$Revision: 1.2 $

Author:
Systemics Ltd
See Also:
MessageDigest, SHAOutputStream, MD5OutputStream

Constructor Summary
MessageDigestOutputStream(MessageDigest md0)
           
 
Method Summary
 byte[] digest()
          Completes the digest and resets.
 MessageHash digestAsHash()
          Completes the digest and resets.
 void write(byte[] b)
          Writes an array of bytes to the message digestor
 void write(byte[] b, int off, int len)
          Writes a sub array of bytes to the message digestor.
 void write(int b)
          Writes a byte to the message digestor.
 
Methods inherited from class java.io.OutputStream
close, flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageDigestOutputStream

public MessageDigestOutputStream(MessageDigest md0)
Parameters:
md0 - the message digestor that is uses to hash the data.
Method Detail

write

public final void write(int b)
Writes a byte to the message digestor.

Parameters:
b - the byte

write

public final void write(byte[] b)
Writes an array of bytes to the message digestor

Parameters:
b - the data to be added to the hash

write

public final void write(byte[] b,
                        int off,
                        int len)
Writes a sub array of bytes to the message digestor.

Parameters:
b - the data to be added to the hash
off - the start offset in the data
len - the number of bytes that are written

digest

public final byte[] digest()
Completes the digest and resets.

Returns:
the final digest (as a byte array) of the data added

digestAsHash

public final MessageHash digestAsHash()
Completes the digest and resets.

Returns:
the final digest (as a Hash object) of the data added