Package com.mku.salmon
Class SalmonEncryptor
java.lang.Object
com.mku.salmon.SalmonEncryptor
Encrypts byte arrays.
- 
Constructor Summary
ConstructorsConstructorDescriptionInstantiate an encryptor.SalmonEncryptor(int threads) Instantiate an encryptor with parallel tasks and buffer size.SalmonEncryptor(int threads, int bufferSize) Instantiate an encryptor with parallel tasks and buffer size. - 
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the decryptor and release associated resourcesbyte[]encrypt(byte[] data, byte[] key, byte[] nonce, boolean storeHeaderData) Encrypt a byte array.byte[]encrypt(byte[] data, byte[] key, byte[] nonce, boolean storeHeaderData, boolean integrity, byte[] hashKey, Integer chunkSize) Encrypts a byte array using the provided key and nonce.protected voidfinalize() 
- 
Constructor Details
- 
SalmonEncryptor
public SalmonEncryptor()Instantiate an encryptor. - 
SalmonEncryptor
public SalmonEncryptor(int threads) Instantiate an encryptor with parallel tasks and buffer size.- Parameters:
 threads- The number of threads to use.
 - 
SalmonEncryptor
public SalmonEncryptor(int threads, int bufferSize) Instantiate an encryptor with parallel tasks and buffer size.- Parameters:
 threads- The number of threads to use.bufferSize- The buffer size to use. It is recommended for performance to use a multiple of the chunk size if you enabled integrity otherwise a multiple of the AES block size (16 bytes).
 
 - 
 - 
Method Details
- 
encrypt
public byte[] encrypt(byte[] data, byte[] key, byte[] nonce, boolean storeHeaderData) throws IOException Encrypt a byte array.- Parameters:
 data- The data to encrypt.key- The key to use.nonce- Nonce to use.storeHeaderData- True to store header data in output byte array.- Returns:
 - The encrypted data
 - Throws:
 SalmonSecurityException- Thrown if there is a security exceptionIntegrityException- Thrown if the data are corrupt or tampered with.IOException- Thrown if there is an IO error.
 - 
encrypt
public byte[] encrypt(byte[] data, byte[] key, byte[] nonce, boolean storeHeaderData, boolean integrity, byte[] hashKey, Integer chunkSize) throws IOException Encrypts a byte array using the provided key and nonce.- Parameters:
 data- The byte array to be encrypted.key- The AES key to be used.nonce- The nonce to be used.storeHeaderData- True if you want to store a header data with the nonce. False if you store the nonce external. Note that you will need to provide the nonce when decrypting.integrity- True if you want to calculate and store hash signatures for each chunkSize.hashKey- Hash key to be used for all chunks.chunkSize- The chunk size.- Returns:
 - The byte array with the encrypted data.
 - Throws:
 SalmonSecurityException- Thrown if there is a security exceptionIOException- Thrown if there is an IO error.IntegrityException- Thrown if the data are corrupt or tampered with.
 - 
close
public void close()Close the decryptor and release associated resources - 
finalize
protected void finalize() 
 -