org.logi.crypto.io
Class HashOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--java.io.FilterOutputStream
              |
              +--org.logi.crypto.io.HashOutputStream

public class HashOutputStream
extends java.io.FilterOutputStream

This OutputStream hashes everything written to it and then passes it to an underlying OutputStream. The hash can be retrieved by calling getFingerprint().

Author:
Logi Ragnarsson (logir@logi.org)
See Also:
HashInputStream

Constructor Summary
HashOutputStream(java.io.OutputStream out)
          Creates a new HashOutputStream around out.
HashOutputStream(java.io.OutputStream out, HashState hashState)
          Creates a new HashOutputStream around out.
 
Method Summary
 void close()
          Closes this output stream and releases any system resources associated with this stream.
 void flush()
          Flushes this output stream and forces any buffered output bytes to be written out to the stream.
 Fingerprint getFingerprint()
          Return a fingerprint of all data written so far.
 void write(byte[] buf, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this output stream.
 void write(int b)
          Writes the specified byte to this output stream.
 
Methods inherited from class java.io.FilterOutputStream
write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashOutputStream

public HashOutputStream(java.io.OutputStream out,
                        HashState hashState)
Creates a new HashOutputStream around out. hashState will be used to calculate fingerprints.

HashOutputStream

public HashOutputStream(java.io.OutputStream out)
Creates a new HashOutputStream around out. A new SHA1State object will be used to calculate fingerprints.
See Also:
SHA1State
Method Detail

getFingerprint

public Fingerprint getFingerprint()
Return a fingerprint of all data written so far.

write

public void write(int b)
           throws java.io.IOException
Writes the specified byte to this output stream.
Overrides:
write in class java.io.FilterOutputStream

write

public void write(byte[] buf,
                  int off,
                  int len)
           throws java.io.IOException
Writes len bytes from the specified byte array starting at offset off to this output stream.
Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException - if there is a problem iwth the underlying stream or the key fails to sign the fingerprint.

flush

public void flush()
           throws java.io.IOException
Flushes this output stream and forces any buffered output bytes to be written out to the stream.
Overrides:
flush in class java.io.FilterOutputStream

close

public void close()
           throws java.io.IOException
Closes this output stream and releases any system resources associated with this stream.
Overrides:
close in class java.io.FilterOutputStream
Throws:
java.io.IOException - if there is a problem with the underlying stream or the key fails to sign the fingerprint.


Copyright 1997-2000 Logi Ragnarsson