All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.io.OutputStream | +----java.io.FilterOutputStream | +----Acme.Crypto.EncryptedOutputStream
This class encapsulates a StreamCipher or BlockCipher as an OutputStream. You set up your cipher, pass it and the underlying stream to the EncryptedOutputStream constructor, and then write your cleartext to this stream. It gets encrypted and sent to the underlying stream. Decryption is done by an EncryptedInputStream.
When used with a StreamCipher, no output protocol is necessary, each byte of cleartext turns into one byte of ciphertext. When used with a BlockCipher it's more complicated. First, the raw BlockCipher gets encapsulated into a CbcBlockCipher, which needs an initialization vector; so each encrypted stream automatically starts off with such a vector. After that, the stream is a series of (block,bytecount) pairs. Each block of cleartext is encrypted into a block of ciphertext, sent to the stream, and then one more byte is sent that says how many bytes in the block are valid. Generally the bytecount will be equal to the block size, but it can be less if the stream gets flushed or closed on a partial block.
Fetch the software.
Fetch the entire Acme package.
public EncryptedOutputStream(BlockCipher blockCipher, OutputStream out) throws IOException
public EncryptedOutputStream(StreamCipher streamCipher, OutputStream out)
public void setKey(String keyStr)
public void setEncrypting(boolean encrypting) throws IOException
public void write(int b) throws IOException
public void write(byte b[], int off, int len) throws IOException
public void flush() throws IOException
All Packages Class Hierarchy This Package Previous Next Index
ACME Java ACME Labs