Package com.jalios.util
Class StringEncrypter
java.lang.Object
com.jalios.util.StringEncrypter
Encrypts and decrypts string using Java Cryptography Extension (JCE)
- Author:
- Javid Jamae - http://www.devx.com/Java/10MinuteSolution/21385
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classException Wrapper for any error that might occur during the encryption or decryption process. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStringEncrypter(String encryptionScheme, String encryptionKey) Create a new StringEncrypter using the specified encryption scheme and key. -
Method Summary
-
Field Details
-
DESEDE_ENCRYPTION_SCHEME
DES3 (DESede) encryption scheme.- See Also:
-
DES_ENCRYPTION_SCHEME
DES encryption scheme.- See Also:
-
-
Constructor Details
-
StringEncrypter
public StringEncrypter(String encryptionScheme, String encryptionKey) throws StringEncrypter.EncryptionException Create a new StringEncrypter using the specified encryption scheme and key.- Parameters:
encryptionScheme- an encryption scheme from one of the following :DESEDE_ENCRYPTION_SCHEMEorDES_ENCRYPTION_SCHEMEencryptionKey- the key to use for the encrypter, must be a valid string of 24 or more characters, must not be null.- Throws:
IllegalArgumentException- if encryptionKey is null or less than 24 charactersStringEncrypter.EncryptionException
-
-
Method Details
-
encrypt
Encrypt the specified string using this StringEncrypter.- Parameters:
unencryptedString- the string to encrypt, must not be null or empty.- Returns:
- the encrypted string.
- Throws:
IllegalArgumentException- if unencryptedString is null or emptyStringEncrypter.EncryptionException
-
decrypt
Decrypt the specified string using this StringEncrypter.- Parameters:
encryptedString- the string to decrypt, must not be null or empty.- Returns:
- the decrypted string.
- Throws:
IllegalArgumentException- if encryptedString is null or emptyStringEncrypter.EncryptionException
-