Class SalmonDecryptor

java.lang.Object
com.mku.salmon.SalmonDecryptor

public class SalmonDecryptor extends Object
Utility class that decrypts byte arrays.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiate 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 Type
    Method
    Description
    void
    Close the decryptor and release associated resources
    byte[]
    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
     

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 exception
      IntegrityException - 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()
      Overrides:
      finalize in class Object