public class TextEncryptor
extends java.lang.Object
Constructor and Description |
---|
TextEncryptor()
Constructs a default AES
TextEncryptor instance using a randomly generated key. |
TextEncryptor(Encryptor encryptor)
Constructs a
TextEncryptor instance using the given Encryptor . |
TextEncryptor(java.security.Key key)
Constructs a default AES
TextEncryptor instance using the given AES key. |
TextEncryptor(java.lang.String password)
Constructs a default AES
TextEncryptor instance using the given password. |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
decrypt(java.lang.String message)
Base64 decodes and decrypts an encrypted message.
|
java.lang.String |
encrypt(java.lang.String message)
Encrypts and Base64 encodes a message.
|
Encryptor |
getEncryptor()
Returns the encryptor.
|
static void |
main(java.lang.String[] args) |
public TextEncryptor()
Constructs a default AES TextEncryptor
instance using a randomly generated key. Obtain the key by calling getEncryptor()
and Encryptor.getKey()
.
public TextEncryptor(java.lang.String password)
Constructs a default AES TextEncryptor
instance using the given password.
password
- the password used for encryptionpublic TextEncryptor(java.security.Key key)
Constructs a default AES TextEncryptor
instance using the given AES key.
key
- the key used for encryptionpublic TextEncryptor(Encryptor encryptor)
Constructs a TextEncryptor
instance using the given Encryptor
.
encryptor
- the encryptor used for encryptionpublic java.lang.String encrypt(java.lang.String message) throws java.security.GeneralSecurityException
Encrypts and Base64 encodes a message.
message
- the messagejava.security.GeneralSecurityException
public java.lang.String decrypt(java.lang.String message) throws java.security.GeneralSecurityException
Base64 decodes and decrypts an encrypted message.
message
- an encrypted messagejava.security.GeneralSecurityException
public Encryptor getEncryptor()
Returns the encryptor.
public static void main(java.lang.String[] args)
args
-