@NotThreadSafe
public final class CipherOutputStream
extends net.java.truecommons.io.DecoratingOutputStream
javax.crypto.CipherOutputStream with some exceptions:
BufferedBlockCipher for ciphering.
flush() method just flushes the underlying output stream
and has no effect on the cipher.
finish() method finishes the output
(probably producing padding bytes) without closing the output.
This can get used in clients to produce a trailer with additional
information about the ciphered data (e.g. a MAC).
CipherReadOnlyChannel| Constructor and Description |
|---|
CipherOutputStream(org.bouncycastle.crypto.BufferedBlockCipher cipher,
java.io.OutputStream out)
Creates a new cipher output stream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
finish()
Finishes and voids this cipher output stream.
|
void |
write(byte[] buf,
int off,
int len)
Ciphers and writes the contents of the given byte array to the
underlying output stream.
|
void |
write(int b)
Ciphers and writes the given byte to the underlying output stream.
|
@CreatesObligation
public CipherOutputStream(org.bouncycastle.crypto.BufferedBlockCipher cipher,
@WillCloseWhenClosed
java.io.OutputStream out)
cipher - the block cipher.out - the output stream.public void write(int b)
throws java.io.IOException
write in class net.java.truecommons.io.DecoratingOutputStreamb - The byte to cipher and write.java.io.IOException - If out or cipher aren't properly initialized,
the stream has been closed or an I/O error occured.public void write(byte[] buf,
int off,
int len)
throws java.io.IOException
write in class net.java.truecommons.io.DecoratingOutputStreambuf - The buffer holding the data to cipher and write.off - The start offset of the data in the buffer.len - The number of bytes to cipher and write.java.io.IOException - If out or cipher aren't properly initialized,
the stream has been closed or an I/O error occured.public void finish()
throws java.io.IOException
java.io.IOException - If out or cipher aren't properly
initialized, an I/O error occurs or the cipher
text is invalid because some required padding is missing.public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class net.java.truecommons.io.DecoratingOutputStreamjava.io.IOException