Package alpine.security.crypto
Class DataEncryption
java.lang.Object
alpine.security.crypto.DataEncryption
This class performs symmetric encryption of data using the system-defined
secret key. The encryption routines in this class require the use of the
unlimited strength policy files, included in the most recent versions of
Java by default. Older Java versions may need to install the policy files
for the methods in this class to function correctly.
- Since:
- 1.3.0
- Author:
- Steve Springett
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]decryptAsBytes(byte[] encryptedIvTextBytes) Decrypts the specified bytes using AES-256.static byte[]decryptAsBytes(SecretKey secretKey, byte[] encryptedIvTextBytes) Decrypts the specified bytes using AES-256.static StringdecryptAsString(String encryptedText) Decrypts the specified string using AES-256.static StringdecryptAsString(SecretKey secretKey, String encryptedText) Decrypts the specified string using AES-256.static byte[]encryptAsBytes(String plainText) Encrypts the specified plainText using AES-256.static byte[]encryptAsBytes(SecretKey secretKey, String plainText) Encrypts the specified plainText using AES-256.static StringencryptAsString(String plainText) Encrypts the specified plainText using AES-256 and returns a Base64 encoded representation of the encrypted bytes.static StringencryptAsString(SecretKey secretKey, String plainText) Encrypts the specified plainText using AES-256 and returns a Base64 encoded representation of the encrypted bytes.
-
Method Details
-
encryptAsBytes
Encrypts the specified plainText using AES-256.- Parameters:
plainText- the text to encryptsecretKey- the secret key to use to encrypt with- Returns:
- the encrypted bytes
- Throws:
Exception- a number of exceptions may be thrown- Since:
- 1.3.0
-
encryptAsBytes
Encrypts the specified plainText using AES-256. This method uses the default secret key.- Parameters:
plainText- the text to encrypt- Returns:
- the encrypted bytes
- Throws:
Exception- a number of exceptions may be thrown- Since:
- 1.3.0
-
encryptAsString
Encrypts the specified plainText using AES-256 and returns a Base64 encoded representation of the encrypted bytes.- Parameters:
secretKey- the secret key to use to encrypt withplainText- the text to encrypt- Returns:
- a Base64 encoded representation of the encrypted bytes
- Throws:
Exception- a number of exceptions may be thrown- Since:
- 1.3.0
-
encryptAsString
Encrypts the specified plainText using AES-256 and returns a Base64 encoded representation of the encrypted bytes. This method uses the default secret key.- Parameters:
plainText- the text to encrypt- Returns:
- a Base64 encoded representation of the encrypted bytes
- Throws:
Exception- a number of exceptions may be thrown- Since:
- 1.3.0
-
decryptAsBytes
public static byte[] decryptAsBytes(SecretKey secretKey, byte[] encryptedIvTextBytes) throws Exception Decrypts the specified bytes using AES-256.- Parameters:
secretKey- the secret key to decrypt withencryptedIvTextBytes- the text to decrypt- Returns:
- the decrypted bytes
- Throws:
Exception- a number of exceptions may be thrown- Since:
- 1.3.0
-
decryptAsBytes
Decrypts the specified bytes using AES-256. This method uses the default secret key.- Parameters:
encryptedIvTextBytes- the text to decrypt- Returns:
- the decrypted bytes
- Throws:
Exception- a number of exceptions may be thrown- Since:
- 1.3.0
-
decryptAsString
Decrypts the specified string using AES-256. The encryptedText is expected to be the Base64 encoded representation of the encrypted bytes generated fromencryptAsString(String).- Parameters:
secretKey- the secret key to decrypt withencryptedText- the text to decrypt- Returns:
- the decrypted string
- Throws:
Exception- a number of exceptions may be thrown- Since:
- 1.3.0
-
decryptAsString
Decrypts the specified string using AES-256. The encryptedText is expected to be the Base64 encoded representation of the encrypted bytes generated fromencryptAsString(String). This method uses the default secret key.- Parameters:
encryptedText- the text to decrypt- Returns:
- the decrypted string
- Throws:
Exception- a number of exceptions may be thrown- Since:
- 1.3.0
-