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