Class TextEncryptor

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

public class TextEncryptor extends Object
Utility class that encrypts text strings.
  • Constructor Details

    • TextEncryptor

      public TextEncryptor()
  • Method Details

    • encryptString

      public static String encryptString(String text, byte[] key, byte[] nonce) 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.
      Returns:
      The encrypted string
      Throws:
      IOException - Thrown if there is an IO error.
      SecurityException - 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, EncryptionFormat format) 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.
      format - The format to use, see EncryptionFormat
      Returns:
      The encrypted string
      Throws:
      IOException - Thrown if there is an IO error.
      SecurityException - 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, EncryptionFormat format, boolean integrity, byte[] hashKey, int 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.
      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 encrypted string.
      Throws:
      IOException - Thrown if there is an IO error.
      SecurityException - 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.