public final class EncryptionUtils extends Object
This class is useful if you have simple needs and wish to use the DESede encryption cipher. More sophisticated requirements will need to use the Java crypto libraries directly.
Modifier and Type | Class and Description |
---|---|
static class |
EncryptionUtils.EncryptionException |
Modifier and Type | Method and Description |
---|---|
static String |
byteArrayToString(byte[] byteArray)
Converts a byte array into a String using UTF-8, falling back to the
platform's default character set if UTF-8 fails.
|
static byte[] |
decrypt(String key,
byte[] inputBytes)
Decrypts the inputBytes using the key.
|
static String |
decrypt(String key,
String inputString)
Decrypts the inputString using the key.
|
static byte[] |
encrypt(String key,
byte[] inputBytes)
Encrypts the inputBytes using the key.
|
static String |
encrypt(String key,
String inputString)
Encrypts the inputString using the key.
|
static byte[] |
stringToByteArray(String input)
Converts a String into a byte array using UTF-8, falling back to the
platform's default character set if UTF-8 fails.
|
public static byte[] stringToByteArray(String input)
input
- the input (required)public static String byteArrayToString(byte[] byteArray)
byteArray
- the byte array to convert (required)public static String encrypt(String key, String inputString) throws EncryptionUtils.EncryptionException
key
- at least 24 character long key (required)inputString
- the string to encrypt (required)EncryptionUtils.EncryptionException
- in the event of an encryption failurepublic static byte[] encrypt(String key, byte[] inputBytes) throws EncryptionUtils.EncryptionException
key
- at least 24 character long key (required)inputBytes
- the bytes to encrypt (required)EncryptionUtils.EncryptionException
- in the event of an encryption failurepublic static String decrypt(String key, String inputString) throws EncryptionUtils.EncryptionException
key
- the key used to originally encrypt the string (required)inputString
- the encrypted string (required)EncryptionUtils.EncryptionException
- in the event of an encryption failurepublic static byte[] decrypt(String key, byte[] inputBytes) throws EncryptionUtils.EncryptionException
key
- the key used to originally encrypt the string (required)inputBytes
- the encrypted bytes (required)EncryptionUtils.EncryptionException
- in the event of an encryption failureCopyright © 2015. All rights reserved.