Package com.mku.salmon.text
Class TextEncryptor
- java.lang.Object
-
- com.mku.salmon.text.TextEncryptor
-
public class TextEncryptor extends java.lang.ObjectUtility class that encrypts text strings.
-
-
Constructor Summary
Constructors Constructor Description TextEncryptor()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringencryptString(java.lang.String text, byte[] key, byte[] nonce)Encrypts a text String using AES256 with the key and nonce provided.static java.lang.StringencryptString(java.lang.String text, byte[] key, byte[] nonce, EncryptionFormat format)Encrypts a text String using AES256 with the key and nonce provided.static java.lang.StringencryptString(java.lang.String text, byte[] key, byte[] nonce, EncryptionFormat format, boolean integrity, byte[] hashKey, int chunkSize)Encrypts a text String using AES256 with the key and nonce provided.
-
-
-
Method Detail
-
encryptString
public static java.lang.String encryptString(java.lang.String text, byte[] key, byte[] nonce) throws java.io.IOExceptionEncrypts 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:
java.io.IOException- Thrown if there is an IO error.SecurityException- Thrown if there is a security exceptionIntegrityException- Thrown if the data are corrupt or tampered with.java.io.IOException- Thrown if there is an IO error.
-
encryptString
public static java.lang.String encryptString(java.lang.String text, byte[] key, byte[] nonce, EncryptionFormat format) throws java.io.IOExceptionEncrypts 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, seeEncryptionFormat- Returns:
- The encrypted string
- Throws:
java.io.IOException- Thrown if there is an IO error.SecurityException- Thrown if there is a security exceptionIntegrityException- Thrown if the data are corrupt or tampered with.java.io.IOException- Thrown if there is an IO error.
-
encryptString
public static java.lang.String encryptString(java.lang.String text, byte[] key, byte[] nonce, EncryptionFormat format, boolean integrity, byte[] hashKey, int chunkSize) throws java.io.IOExceptionEncrypts 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, seeEncryptionFormatintegrity- 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:
java.io.IOException- Thrown if there is an IO error.SecurityException- Thrown if there is a security exceptionIntegrityException- Thrown if the data are corrupt or tampered with.java.io.IOException- Thrown if there is an IO error.
-
-