Package com.mku.salmon
Class SalmonDecryptor
java.lang.Object
com.mku.salmon.SalmonDecryptor
Utility class that decrypts byte arrays.
-
Constructor Summary
ConstructorDescriptionInstantiate an encryptor.SalmonDecryptor
(int threads) Instantiate an encryptor with parallel tasks and buffer size.SalmonDecryptor
(int threads, int bufferSize) Instantiate an encryptor with parallel tasks and buffer size. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the decryptor and release associated resourcesbyte[]
decrypt
(byte[] data, byte[] key, byte[] nonce, boolean hasHeaderData) Decrypts a byte array using parallel threads.byte[]
decrypt
(byte[] data, byte[] key, byte[] nonce, boolean hasHeaderData, boolean integrity, byte[] hashKey, Integer chunkSize) Decrypt a byte array using AES256 based on the provided key and nonce.protected void
finalize()
-
Constructor Details
-
SalmonDecryptor
public SalmonDecryptor()Instantiate an encryptor. -
SalmonDecryptor
public SalmonDecryptor(int threads) Instantiate an encryptor with parallel tasks and buffer size.- Parameters:
threads
- The number of threads to use.
-
SalmonDecryptor
public SalmonDecryptor(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
-
decrypt
public byte[] decrypt(byte[] data, byte[] key, byte[] nonce, boolean hasHeaderData) throws IOException Decrypts a byte array using parallel threads.- Parameters:
data
- The input data to be decrypted.key
- The AES key to use for decryption.nonce
- The nonce to use for decryption.hasHeaderData
- The header data.- Returns:
- The output buffer containing the decrypted data.
- Throws:
IOException
- Thrown if there is an error with the stream.SalmonSecurityException
- Thrown if there is a security exceptionIntegrityException
- Thrown if the data are corrupt or tampered with.
-
decrypt
public byte[] decrypt(byte[] data, byte[] key, byte[] nonce, boolean hasHeaderData, boolean integrity, byte[] hashKey, Integer chunkSize) throws IOException Decrypt a byte array using AES256 based on the provided key and nonce.- Parameters:
data
- The input data to be decrypted.key
- The AES key to use for decryption.nonce
- The nonce to use for decryption.hasHeaderData
- The header data.integrity
- Verify hash integrity in the data.hashKey
- The hash key to be used for integrity.chunkSize
- The chunk size.- Returns:
- The byte array with the decrypted data.
- Throws:
IOException
- Thrown if there is a problem with decoding the array.SalmonSecurityException
- Thrown if the key and nonce are not provided.IOException
- 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()
-