org.cryptonode.jncryptor
Class AES256JNCryptorOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.cryptonode.jncryptor.AES256JNCryptorOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class AES256JNCryptorOutputStream
extends OutputStream

Writes RNCryptor-format (version 3) data in a stream fashion. The stream must be closed to finish writing the data and output the HMAC value.

Since:
1.1.0

Constructor Summary
AES256JNCryptorOutputStream(OutputStream out, char[] password)
          Creates an output stream for password-encrypted data.
AES256JNCryptorOutputStream(OutputStream out, char[] password, int iterations)
          Creates an output stream for password-encrypted data, using a specific number of PBKDF iterations.
AES256JNCryptorOutputStream(OutputStream out, SecretKey encryptionKey, SecretKey hmacKey)
          Creates an output stream for key-encrypted data.
 
Method Summary
 void close()
          Closes the stream.
 void write(byte[] b, int off, int len)
          Writes bytes to the encrypted output stream.
 void write(int b)
          Writes one byte to the encrypted output stream.
 
Methods inherited from class java.io.OutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AES256JNCryptorOutputStream

public AES256JNCryptorOutputStream(OutputStream out,
                                   SecretKey encryptionKey,
                                   SecretKey hmacKey)
                            throws CryptorException
Creates an output stream for key-encrypted data.

Parameters:
out - the OutputStream to write the JNCryptor data to
encryptionKey - the key to encrypt with
hmacKey - the key to calculate the HMAC with
Throws:
CryptorException

AES256JNCryptorOutputStream

public AES256JNCryptorOutputStream(OutputStream out,
                                   char[] password,
                                   int iterations)
                            throws CryptorException
Creates an output stream for password-encrypted data, using a specific number of PBKDF iterations.

Parameters:
out - the OutputStream to write the JNCryptor data to
password - the password
iterations - the number of PBKDF iterations to perform
Throws:
CryptorException

AES256JNCryptorOutputStream

public AES256JNCryptorOutputStream(OutputStream out,
                                   char[] password)
                            throws CryptorException
Creates an output stream for password-encrypted data.

Parameters:
out - the OutputStream to write the JNCryptor data to
password - the password
Throws:
CryptorException
Method Detail

write

public void write(int b)
           throws IOException
Writes one byte to the encrypted output stream.

Specified by:
write in class OutputStream
Parameters:
b - the byte to write
Throws:
IOException - if an I/O error occurs

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Writes bytes to the encrypted output stream.

Overrides:
write in class OutputStream
Parameters:
b - a buffer of bytes to write
off - the offset into the buffer
len - the number of bytes to write (starting from the offset)
Throws:
IOException - if an I/O error occurs

close

public void close()
           throws IOException
Closes the stream. This causes the HMAC calculation to be concluded and written to the output.

Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException - if an I/O error occurs


Copyright © 2014. All Rights Reserved.