Package org.jasypt.util.text
Class StrongTextEncryptor
- java.lang.Object
-
- org.jasypt.util.text.StrongTextEncryptor
-
- All Implemented Interfaces:
TextEncryptor
public final class StrongTextEncryptor extends java.lang.Object implements TextEncryptor
Utility class for easily performing high-strength encryption of texts.
This class internally holds a
StandardPBEStringEncryptor
configured this way:- Algorithm: PBEWithMD5AndTripleDES.
- Key obtention iterations: 1000.
The required steps to use it are:
- Create an instance (using new).
- Set a password (using
setPassword(String)
orsetPasswordCharArray(char[])
). - Perform the desired
encrypt(String)
ordecrypt(String)
operations.
To use this class, you may need to download and install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files.
This class is thread-safe.
- Since:
- 1.2 (class existed in org.jasypt.util package since 1.0)
-
-
Field Summary
Fields Modifier and Type Field Description private StandardPBEStringEncryptor
encryptor
-
Constructor Summary
Constructors Constructor Description StrongTextEncryptor()
Creates a new instance of StrongTextEncryptor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
decrypt(java.lang.String encryptedMessage)
Decrypts a message.java.lang.String
encrypt(java.lang.String message)
Encrypts a message.void
setPassword(java.lang.String password)
Sets a password.void
setPasswordCharArray(char[] password)
Sets a password, as a char[].
-
-
-
Field Detail
-
encryptor
private final StandardPBEStringEncryptor encryptor
-
-
Method Detail
-
setPassword
public void setPassword(java.lang.String password)
Sets a password.- Parameters:
password
- the password to be set.
-
setPasswordCharArray
public void setPasswordCharArray(char[] password)
Sets a password, as a char[].- Parameters:
password
- the password to be set.- Since:
- 1.8
-
encrypt
public java.lang.String encrypt(java.lang.String message)
Encrypts a message.- Specified by:
encrypt
in interfaceTextEncryptor
- Parameters:
message
- the message to be encrypted.- See Also:
StandardPBEStringEncryptor.encrypt(String)
-
decrypt
public java.lang.String decrypt(java.lang.String encryptedMessage)
Decrypts a message.- Specified by:
decrypt
in interfaceTextEncryptor
- Parameters:
encryptedMessage
- the message to be decrypted.- See Also:
StandardPBEStringEncryptor.decrypt(String)
-
-