Class SalmonTextEncryptor

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

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

    • SalmonTextEncryptor

      public SalmonTextEncryptor()
  • Method Details

    • encryptString

      public static String encryptString(String text, byte[] key, byte[] nonce, boolean header) throws IOException
      Encrypts a text String using AES256 with the key and nonce provided.
      Parameters:
      text - Text to be encrypted.
      key - The encryption key to be used.
      nonce - The nonce to be used.
      header - Set to true to store a header with information like nonce and/or chunk size, otherwise you will have to store that information externally.
      Returns:
      The encrypted string
      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.
      IOException - Thrown if there is an IO error.
    • encryptString

      public static String encryptString(String text, byte[] key, byte[] nonce, boolean header, boolean integrity, byte[] hashKey, Integer chunkSize) throws IOException
      Encrypts a text String using AES256 with the key and nonce provided.
      Parameters:
      text - Text to be encrypted.
      key - The encryption key to be used.
      nonce - The nonce to be used.
      header - Set to true to store a header with information like nonce and/or chunk size, otherwise you will have to store that information externally.
      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 encrypted string.
      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.
      IOException - Thrown if there is an IO error.