@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(BufferedBlockCipher cipher,
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(BufferedBlockCipher cipher, @WillCloseWhenClosed OutputStream out)
cipher
- the block cipher.out
- the output stream.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class net.java.truecommons.io.DecoratingOutputStream
IOException
public void finish() throws IOException
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 write(byte[] buf, int off, int len) throws IOException
write
in class net.java.truecommons.io.DecoratingOutputStream
buf
- 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.IOException
- If out or cipher aren't properly initialized,
the stream has been closed or an I/O error occured.public void write(int b) throws IOException
write
in class net.java.truecommons.io.DecoratingOutputStream
b
- The byte to cipher and write.IOException
- If out or cipher aren't properly initialized,
the stream has been closed or an I/O error occured.Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.