T - the concrete type of this encryptor object.public abstract class AbstractValueEncryptor<T extends AbstractValueEncryptor<T>> extends AbstractEncryptor<T> implements ValueEncryptorInterface<T>
| Constructor and Description |
|---|
AbstractValueEncryptor()
Initializes the AbstractValueEncryptor with a
HexEncoder used for encoding/decoding byte
arrays, and a default charset of UTF-8. |
AbstractValueEncryptor(TextEncoder textEncoder)
Initializes the AbstractValueEncryptor with the given
TextEncoder used for
encoding/decoding byte arrays, and a default charset of UTF-8. |
AbstractValueEncryptor(TextEncoder textEncoder,
Charset charset)
Initializes the AbstractValueEncryptor with the given
TextEncoder and
Charset used for encoding/decoding byte arrays. |
| Modifier and Type | Method and Description |
|---|---|
String |
decrypt(String text)
Returns the decoded and decrypted text for the given text representation.
|
String |
decrypt(String text,
Key key)
Returns the decoded and decrypted text for the given text representation, using the given
Key. |
byte[] |
decryptAndDecode(String text)
Returns the decoded and decrypted bytes for the given text representation.
|
byte[] |
decryptAndDecode(String text,
Key key)
Returns the decoded and decrypted bytes for the given text representation, using the given
Key. |
Boolean |
decryptBoolean(String text)
Returns the decoded and decrypted boolean for the given text representation.
|
Boolean |
decryptBoolean(String text,
Key key)
Returns the decoded and decrypted boolean for the given text representation, using the given
Key. |
Character |
decryptCharacter(String text)
Returns the decoded and decrypted character for the given text representation.
|
Character |
decryptCharacter(String text,
Key key)
Returns the decoded and decrypted character for the given text representation, using the given
Key. |
Double |
decryptDouble(String text)
Returns the decoded and decrypted double for the given text representation.
|
Double |
decryptDouble(String text,
Key key)
Returns the decoded and decrypted double for the given text representation, using the given
Key. |
Float |
decryptFloat(String text)
Returns the decoded and decrypted float for the given text representation.
|
Float |
decryptFloat(String text,
Key key)
Returns the decoded and decrypted float for the given text representation, using the given
Key. |
Integer |
decryptInteger(String text)
Returns the decoded and decrypted integer for the given text representation.
|
Integer |
decryptInteger(String text,
Key key)
Returns the decoded and decrypted integer for the given text representation, using the given
Key. |
Long |
decryptLong(String text)
Returns the decoded and decrypted long for the given text representation.
|
Long |
decryptLong(String text,
Key key)
Returns the decoded and decrypted long for the given text representation, using the given
Key. |
Object |
decryptObject(String text)
Returns the decoded and decrypted object for the given text representation.
|
Object |
decryptObject(String text,
Key key)
Returns the decoded and decrypted object for the given text representation, using the given
Key. |
Short |
decryptShort(String text)
Returns the decoded and decrypted short for the given text representation.
|
Short |
decryptShort(String text,
Key key)
Returns the decoded and decrypted short for the given text representation, using the given
Key. |
String |
encrypt(String text)
Returns an encrypted and encoded text representation of the given text.
|
String |
encrypt(String text,
Key key)
Returns an encrypted and encoded text representation of the given text, using the given
Key. |
String |
encryptAndEncode(byte[] bytes)
Returns an encrypted and encoded text representation of the given bytes.
|
String |
encryptAndEncode(byte[] bytes,
Key key)
Returns an encrypted and encoded text representation of the given bytes, using the given
Key. |
String |
encryptBoolean(Boolean value)
Returns an encrypted and encoded text representation of the given boolean.
|
String |
encryptBoolean(Boolean value,
Key key)
Returns an encrypted and encoded text representation of the given boolean, using the given
Key. |
String |
encryptCharacter(Character number)
Returns an encrypted and encoded text representation of the given character.
|
String |
encryptCharacter(Character number,
Key key)
Returns an encrypted and encoded text representation of the given character, using the given
Key. |
String |
encryptDouble(Double number)
Returns an encrypted and encoded text representation of the given double.
|
String |
encryptDouble(Double number,
Key key)
Returns an encrypted and encoded text representation of the given double, using the given
Key. |
String |
encryptFloat(Float number)
Returns an encrypted and encoded text representation of the given float.
|
String |
encryptFloat(Float number,
Key key)
Returns an encrypted and encoded text representation of the given float, using the given
Key. |
String |
encryptInteger(Integer number)
Returns an encrypted and encoded text representation of the given integer.
|
String |
encryptInteger(Integer number,
Key key)
Returns an encrypted and encoded text representation of the given integer, using the given
Key. |
String |
encryptLong(Long number)
Returns an encrypted and encoded text representation of the given long.
|
String |
encryptLong(Long number,
Key key)
Returns an encrypted and encoded text representation of the given long, using the given
Key. |
String |
encryptObject(Object object)
Returns an encrypted and encoded text representation of the given object.
|
String |
encryptObject(Object object,
Key key)
Returns an encrypted and encoded text representation of the given object, using the given
Key. |
String |
encryptShort(Short number)
Returns an encrypted and encoded text representation of the given short.
|
String |
encryptShort(Short number,
Key key)
Returns an encrypted and encoded text representation of the given short, using the given
Key. |
Charset |
getCharset()
Returns the charset.
|
decrypt, decrypt, encrypt, encrypt, getAlgorithmParameters, initialize, isInitialized, setAlgorithmParametersclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdecrypt, decrypt, encrypt, encrypt, getAlgorithmParameters, initialize, isInitialized, setAlgorithmParameterspublic AbstractValueEncryptor()
HexEncoder used for encoding/decoding byte
arrays, and a default charset of UTF-8.public AbstractValueEncryptor(TextEncoder textEncoder)
TextEncoder used for
encoding/decoding byte arrays, and a default charset of UTF-8.textEncoder - the TextEncoder used for encoding/decoding byte arrayspublic AbstractValueEncryptor(TextEncoder textEncoder, Charset charset)
TextEncoder and
Charset used for encoding/decoding byte arrays.textEncoder - the TextEncoder used for encoding/decoding byte arrayscharset - Charset to be used during encryption/decryptionpublic String encrypt(String text) throws GeneralSecurityException
encrypt in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be encryptedGeneralSecurityException - GeneralSecurityExceptionpublic String decrypt(String text) throws GeneralSecurityException
encrypt method.decrypt in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be decryptedGeneralSecurityException - GeneralSecurityExceptionpublic String encryptAndEncode(byte[] bytes) throws GeneralSecurityException
encryptAndEncode in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>bytes - the bytes to be encryptedGeneralSecurityException - GeneralSecurityExceptionpublic byte[] decryptAndDecode(String text) throws GeneralSecurityException
encryptAndEncode method.decryptAndDecode in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be decryptedGeneralSecurityException - GeneralSecurityExceptionpublic String encryptCharacter(Character number) throws GeneralSecurityException
encryptCharacter in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>number - the character to be encryptedGeneralSecurityException - GeneralSecurityExceptionpublic Character decryptCharacter(String text) throws GeneralSecurityException
encryptCharacter method.decryptCharacter in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the character to be decryptedGeneralSecurityException - GeneralSecurityExceptionpublic String encryptLong(Long number) throws GeneralSecurityException
encryptLong in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>number - the long to be encryptedGeneralSecurityException - GeneralSecurityExceptionpublic Long decryptLong(String text) throws GeneralSecurityException
encryptLong method.decryptLong in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be decryptedGeneralSecurityException - GeneralSecurityExceptionpublic String encryptInteger(Integer number) throws GeneralSecurityException
encryptInteger in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>number - the integer to be encryptedGeneralSecurityException - GeneralSecurityExceptionpublic Integer decryptInteger(String text) throws GeneralSecurityException
encryptInteger method.decryptInteger in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be decryptedGeneralSecurityException - GeneralSecurityExceptionpublic String encryptShort(Short number) throws GeneralSecurityException
encryptShort in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>number - the short to be encryptedGeneralSecurityException - GeneralSecurityExceptionpublic Short decryptShort(String text) throws GeneralSecurityException
encryptShort method.decryptShort in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be decryptedGeneralSecurityException - GeneralSecurityExceptionpublic String encryptBoolean(Boolean value) throws GeneralSecurityException
encryptBoolean in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>value - the short to be encryptedGeneralSecurityException - GeneralSecurityExceptionpublic Boolean decryptBoolean(String text) throws GeneralSecurityException
encryptBoolean method.decryptBoolean in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be decryptedGeneralSecurityException - GeneralSecurityExceptionpublic String encryptDouble(Double number) throws GeneralSecurityException
encryptDouble in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>number - the double to be encryptedGeneralSecurityException - GeneralSecurityExceptionpublic Double decryptDouble(String text) throws GeneralSecurityException
encryptDouble method.decryptDouble in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the double to be decryptedGeneralSecurityException - GeneralSecurityExceptionpublic String encryptFloat(Float number) throws GeneralSecurityException
encryptFloat in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>number - the float to be encryptedGeneralSecurityException - GeneralSecurityExceptionpublic Float decryptFloat(String text) throws GeneralSecurityException
encryptFloat method.decryptFloat in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the float to be decryptedGeneralSecurityException - GeneralSecurityExceptionpublic String encryptObject(Object object) throws GeneralSecurityException, IOException
Serializable.encryptObject in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>object - the object to be encryptedGeneralSecurityException - GeneralSecurityExceptionIOException - IOExceptionpublic Object decryptObject(String text) throws GeneralSecurityException, IOException, ClassNotFoundException
encryptObject method.decryptObject in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be decryptedGeneralSecurityException - GeneralSecurityExceptionIOException - IOExceptionClassNotFoundException - ClassNotFoundExceptionpublic String encrypt(String text, Key key) throws GeneralSecurityException
Key.encrypt in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be encryptedkey - the encryption keyGeneralSecurityException - GeneralSecurityExceptionpublic String decrypt(String text, Key key) throws GeneralSecurityException
Key. This
method will only work with data encrypted using the encrypt method.decrypt in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be decryptedkey - the decryption keyGeneralSecurityException - GeneralSecurityExceptionpublic String encryptAndEncode(byte[] bytes, Key key) throws GeneralSecurityException
Key.encryptAndEncode in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>bytes - the bytes to be encryptedkey - the encryption keyGeneralSecurityException - GeneralSecurityExceptionpublic byte[] decryptAndDecode(String text, Key key) throws GeneralSecurityException
Key. This
method will only work with data encrypted using the encryptAndEncode method.decryptAndDecode in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be decryptedkey - the decryption keyGeneralSecurityException - GeneralSecurityExceptionpublic String encryptCharacter(Character number, Key key) throws GeneralSecurityException
Key.encryptCharacter in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>number - the character to be encryptedkey - the encryption keyGeneralSecurityException - GeneralSecurityExceptionpublic Character decryptCharacter(String text, Key key) throws GeneralSecurityException
Key.
This method will only work with data encrypted using the encryptCharacter method.decryptCharacter in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the character to be decryptedkey - the decryption keyGeneralSecurityException - GeneralSecurityExceptionpublic String encryptLong(Long number, Key key) throws GeneralSecurityException
Key. This is
generally the most efficient means of encrypting a long, as the byte representation is used for encryption rather
than the string representation.encryptLong in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>number - the long to be encryptedkey - the encryption keyGeneralSecurityException - GeneralSecurityExceptionpublic Long decryptLong(String text, Key key) throws GeneralSecurityException
Key. This
method will only work with data encrypted using the encryptLong method.decryptLong in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be decryptedkey - the decryption keyGeneralSecurityException - GeneralSecurityExceptionpublic String encryptInteger(Integer number, Key key) throws GeneralSecurityException
Key. This
is generally the most efficient means of encrypting an integer, as the byte representation is used for encryption
rather than the string representation.encryptInteger in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>number - the integer to be encryptedkey - the encryption keyGeneralSecurityException - GeneralSecurityExceptionpublic Integer decryptInteger(String text, Key key) throws GeneralSecurityException
Key.
This method will only work with data encrypted using the encryptInteger method.decryptInteger in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be decryptedkey - the decryption keyGeneralSecurityException - GeneralSecurityExceptionpublic String encryptShort(Short number, Key key) throws GeneralSecurityException
Key. This
is generally the most efficient means of encrypting a short, as the byte representation is used for encryption
rather than the string representation.encryptShort in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>number - the short to be encryptedkey - the encryption keyGeneralSecurityException - GeneralSecurityExceptionpublic Short decryptShort(String text, Key key) throws GeneralSecurityException
Key. This
method will only work with data encrypted using the encryptShort method.decryptShort in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be decryptedkey - the decryption keyGeneralSecurityException - GeneralSecurityExceptionpublic String encryptBoolean(Boolean value, Key key) throws GeneralSecurityException
Key. This
is generally the most efficient means of encrypting a boolean, as the bit representation is used for encryption
rather than the string representation.encryptBoolean in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>value - the short to be encryptedkey - the encryption keyGeneralSecurityException - GeneralSecurityExceptionpublic Boolean decryptBoolean(String text, Key key) throws GeneralSecurityException
Key.
This method will only work with data encrypted using the encryptBoolean method.decryptBoolean in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be decryptedkey - the decryption keyGeneralSecurityException - GeneralSecurityExceptionpublic String encryptDouble(Double number, Key key) throws GeneralSecurityException
Key. This
is generally the most efficient means of encrypting a double, as the byte representation is used for encryption
rather than the string representation.encryptDouble in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>number - the double to be encryptedkey - the encryption keyGeneralSecurityException - GeneralSecurityExceptionpublic Double decryptDouble(String text, Key key) throws GeneralSecurityException
Key.
This method will only work with data encrypted using the encryptDouble method.decryptDouble in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the double to be decryptedkey - the decryption keyGeneralSecurityException - GeneralSecurityExceptionpublic String encryptFloat(Float number, Key key) throws GeneralSecurityException
Key. This
is generally the most efficient means of encrypting a float, as the byte representation is used for encryption
rather than the string representation.encryptFloat in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>number - the float to be encryptedkey - the encryption keyGeneralSecurityException - GeneralSecurityExceptionpublic Float decryptFloat(String text, Key key) throws GeneralSecurityException
Key. This
method will only work with data encrypted using the encryptFloat method.decryptFloat in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the float to be decryptedkey - the decryption keyGeneralSecurityException - GeneralSecurityExceptionpublic String encryptObject(Object object, Key key) throws GeneralSecurityException, IOException
Key. The
object should implement Serializable.encryptObject in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>object - the object to be encryptedkey - the encryption keyGeneralSecurityException - GeneralSecurityExceptionIOException - IOExceptionpublic Object decryptObject(String text, Key key) throws GeneralSecurityException, IOException, ClassNotFoundException
Key.
This method will only work with data encrypted using the encryptObject method.decryptObject in interface ValueEncryptorInterface<T extends AbstractValueEncryptor<T>>text - the text to be decryptedkey - the decryption keyGeneralSecurityException - GeneralSecurityExceptionIOException - IOExceptionClassNotFoundException - ClassNotFoundExceptionpublic Charset getCharset()
getCharset in interface EncryptorInterface<T extends AbstractValueEncryptor<T>>