Package com.mku.salmon
Class Encryptor
- java.lang.Object
- 
- com.mku.salmon.Encryptor
 
- 
 public class Encryptor extends java.lang.ObjectEncrypts byte arrays.
- 
- 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the decryptor and release associated resourcesbyte[]encrypt(byte[] data, byte[] key, byte[] nonce)Encrypt a byte array and embedded the nonce.byte[]encrypt(byte[] data, byte[] key, byte[] nonce, EncryptionFormat format)Encrypt a byte array.byte[]encrypt(byte[] data, byte[] key, byte[] nonce, EncryptionFormat format, boolean integrity, byte[] hashKey)Encrypts a byte array using the nonce, the integrity hash key.byte[]encrypt(byte[] data, byte[] key, byte[] nonce, EncryptionFormat format, boolean integrity, byte[] hashKey, int chunkSize)Encrypts a byte array using the nonce, the integrity hash key, and the chunk size.
 
- 
- 
- 
Constructor Detail- 
Encryptorpublic Encryptor() Instantiate an encryptor.
 - 
Encryptorpublic Encryptor(int threads) Instantiate an encryptor with parallel tasks and buffer size.- Parameters:
- threads- The number of threads to use.
 
 - 
Encryptorpublic Encryptor(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 Detail- 
encryptpublic byte[] encrypt(byte[] data, byte[] key, byte[] nonce) throws java.io.IOExceptionEncrypt a byte array and embedded the nonce.- Parameters:
- data- The data to encrypt.
- key- The key to use.
- nonce- Nonce to use.
- Returns:
- The encrypted data
- Throws:
- SecurityException- Thrown if there is a security exception
- IntegrityException- Thrown if the data are corrupt or tampered with.
- java.io.IOException- Thrown if there is an IO error.
 
 - 
encryptpublic byte[] encrypt(byte[] data, byte[] key, byte[] nonce, EncryptionFormat format) throws java.io.IOExceptionEncrypt a byte array.- Parameters:
- data- The data to encrypt.
- key- The key to use.
- nonce- Nonce to use.
- format- The format to use, see- EncryptionFormat
- Returns:
- The encrypted data
- Throws:
- SecurityException- Thrown if there is a security exception
- IntegrityException- Thrown if the data are corrupt or tampered with.
- java.io.IOException- Thrown if there is an IO error.
 
 - 
encryptpublic byte[] encrypt(byte[] data, byte[] key, byte[] nonce, EncryptionFormat format, boolean integrity, byte[] hashKey) throws java.io.IOExceptionEncrypts a byte array using the nonce, the integrity hash key.- Parameters:
- data- The byte array to be encrypted.
- key- The AES key to be used.
- nonce- The nonce to be used.
- format- The format to use, see- EncryptionFormat
- integrity- True if you want to calculate and store hash signatures for each chunkSize.
- hashKey- Hash key to be used for all chunks.
- Returns:
- The byte array with the encrypted data.
- Throws:
- SecurityException- Thrown if there is a security exception
- java.io.IOException- Thrown if there is an IO error.
- IntegrityException- Thrown if the data are corrupt or tampered with.
 
 - 
encryptpublic byte[] encrypt(byte[] data, byte[] key, byte[] nonce, EncryptionFormat format, boolean integrity, byte[] hashKey, int chunkSize) throws java.io.IOExceptionEncrypts a byte array using the nonce, the integrity hash key, and the chunk size.- Parameters:
- data- The byte array to be encrypted.
- key- The AES key to be used.
- nonce- The nonce to be used.
- format- The format to use, see- EncryptionFormat
- 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:
- SecurityException- Thrown if there is a security exception
- java.io.IOException- Thrown if there is an IO error.
- IntegrityException- Thrown if the data are corrupt or tampered with.
 
 - 
closepublic void close() Close the decryptor and release associated resources
 
- 
 
-