Class SalmonTextDecryptor

java.lang.Object
com.mku.salmon.text.SalmonTextDecryptor

public class SalmonTextDecryptor extends Object
Utility class that encrypts and decrypts text strings.
  • Constructor Details

    • SalmonTextDecryptor

      public SalmonTextDecryptor()
  • Method Details

    • decryptString

      public static String decryptString(String text, byte[] key, byte[] nonce, boolean header) throws IOException
      Decrypts a text String using AES256 with the key and nonce provided.
      Parameters:
      text - Text to be decrypted.
      key - The encryption key to be used.
      nonce - The nonce to be used, set only if header=false.
      header - Set to true if you encrypted the string with encrypt(header=true), set only if nonce=null otherwise you will have to provide the original nonce.
      Returns:
      The decrypted text.
      Throws:
      IOException - Thrown if there is an IO error.
      SalmonSecurityException - Thrown if there is a security exception
      IntegrityException - Thrown if the data are corrupt or tampered with.
    • decryptString

      public static String decryptString(String text, byte[] key, byte[] nonce, boolean header, boolean integrity, byte[] hashKey, Integer chunkSize) throws IOException
      Decrypts a text String using AES256 with the key and nonce provided.
      Parameters:
      text - Text to be decrypted.
      key - The encryption key to be used.
      nonce - The nonce to be used, set only if header=false.
      header - Set to true if you encrypted the string with encrypt(header=true), set only if nonce=null otherwise you will have to provide the original nonce.
      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 decrypted text.
      Throws:
      IOException - Thrown if there is an IO error.
      SalmonSecurityException - Thrown if there is a security exception
      IntegrityException - Thrown if the data are corrupt or tampered with.