Package com.mku.salmon.text
Class SalmonTextEncryptor
java.lang.Object
com.mku.salmon.text.SalmonTextEncryptor
Utility class that encrypts and decrypts text strings.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringencryptString(String text, byte[] key, byte[] nonce, boolean header) Encrypts a text String using AES256 with the key and nonce provided.static StringencryptString(String text, byte[] key, byte[] nonce, boolean header, boolean integrity, byte[] hashKey, Integer chunkSize) Encrypts a text String using AES256 with the key and nonce provided.
-
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 exceptionIntegrityException- 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 chunkSizehashKey- 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 exceptionIntegrityException- Thrown if the data are corrupt or tampered with.IOException- Thrown if there is an IO error.
-