h36532 s 00003/00003/00231 d D 1.4 97/12/09 15:24:43 luehe 5 4 c rm ,* e s 00000/00022/00234 d D 1.3 97/10/22 15:25:07 luehe 4 3 c removed examples e s 00032/00011/00224 d D 1.2 97/10/18 13:59:53 luehe 3 1 c removed examples e s 00000/00000/00000 d R 1.2 97/10/09 09:58:14 Codemgr 2 1 c SunPro Code Manager data about conflicts, renames, etc... c Name history : 1 0 security/JCE1.2/earlyaccess/javax.crypto.CipherOutputStream.html e s 00235/00000/00000 d D 1.1 97/10/09 09:58:13 luehe 1 0 c date and time created 97/10/09 09:58:13 by luehe e u U f e 0 t T I 1
D 3 E 3 I 3 D 5 E 5 I 5 E 5 E 3D 3 All Packages Class Hierarchy This Package Previous Next IndexE 3 I 3 D 5 All Packages Class Hierarchy This Package Previous Next Index E 5 I 5 All Packages Class Hierarchy This Package Previous Next Index E 5 E 3
java.lang.Object | +----java.io.OutputStream | +----java.io.FilterOutputStream | +----javax.crypto.CipherOutputStream
For example, if the Cipher is initialized for decryption, the SecureOutputStream will attempt to encrypt data before writing out the encrypted data. E 3 I 3 initialized before being used by a CipherOutputStream.
For example, if the Cipher is initialized for encryption, the CipherOutputStream will attempt to encrypt data before writing out the encrypted data. E 3
This class adheres strictly to the semantics, especially the D 3 failure semantics, given for its ancestor classes E 3 I 3 failure semantics, of its ancestor classes E 3 java.io.OutputStream and java.io.FilterOutputStream. This class has exactly those methods specified in its ancestor classes, and D 3 override them all. Moreover, this class catches all exceptions E 3 I 3 overrides them all. Moreover, this class catches all exceptions E 3 that are not thrown by its ancestor classes. D 3
It is crucial for a programmer using this class to not to use E 3 I 3
It is crucial for a programmer using this class not to use E 3 methods that are not defined or overriden in this class (such as a new method or constructor that is later added to one of the super classes), because the design and implementation of those methods are unlikely to have considered security impact with regard to CipherOutputStream. D 3
code example ... E 3 I 3 D 4
The following example demonstrates the usage of CipherOutputStream,
where several instances of CipherOutputStream and OutputStream are
connected.
It is assumed that cipher1
and cipher2
have
been initialized for decryption and encryption (with corresponding
keys), respectively.
The above program copies the content from file /tmp/a.txt to /tmp/b.txt,
except that the content is first encrypted and then decrypted back before
it is written to /tmp/b.txt.
E 4
E 3
FileInputStream fis = new FileInputStream("/tmp/a.txt");
FileOutputStream fos = new FileOutputStream("/tmp/b.txt");
CipherOutputStream cos1 = new CipherOutputStream(fos, cipher1);
CipherOutputStream cos2 = new CipherOutputStream(cos1, cipher2);
byte[] b = new byte[8];
int i = fis.read(b);
while (i != -1) {
cos2.write(b, 0, i);
i = fis.read(b);
}
cos2.flush();
b.length
bytes from the specified byte array
to this output stream.
len
bytes from the specified byte array
starting at offset off
to this output stream.
public CipherOutputStream(OutputStream os, Cipher c)
protected CipherOutputStream(OutputStream os)
public void write(int b) throws IOException
byte
.
public void write(byte b[]) throws IOException
b.length
bytes from the specified byte array
to this output stream.
The write
method of
CipherOutputStream
calls the write
method of three arguments with the three arguments
b
, 0
, and b.length
.
public void write(byte b[], int off, int len) throws IOException
len
bytes from the specified byte array
starting at offset off
to this output stream.
public void flush() throws IOException
public void close() throws IOException
The close
method of CipherOutputStream
calls its flush
method, and then calls the
close
method of its underlying output stream.
D 3 All Packages Class Hierarchy This Package Previous Next IndexE 3 I 3 D 5 All Packages Class Hierarchy This Package Previous Next Index E 5 I 5 All Packages Class Hierarchy This Package Previous Next Index E 5 E 3 E 1