org.logi.crypto.io
Class HashOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byjava.io.FilterOutputStream
          extended byorg.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().

See Also:
HashInputStream

Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
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
clone, equals, finalize, 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.

Throws:
java.io.IOException

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.

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.

Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Closes this output stream and releases any system resources associated with this stream.

Throws:
java.io.IOException - if there is a problem with the underlying stream or the key fails to sign the fingerprint.