public class BasicCryptor extends Object implements Cryptor
Public methods in this class throw only CryptoException
s.
Modifier and Type | Field and Description |
---|---|
protected String |
cipherAlgorithm |
protected Key |
decryptKey
The key to be used for decryption.
|
static String |
ENCRYPT_PREFIX |
protected Cipher |
encryptCipher
The
Cipher to use for encryption. |
static String |
OLD_ENCRYPT_PREFIX |
Constructor and Description |
---|
BasicCryptor(Key encryptKey,
Key decryptKey,
String algorithm,
IvParameterSpec iv) |
Modifier and Type | Method and Description |
---|---|
byte[] |
decrypt(byte[] ciphertext)
Decrypt the ciphertext to yield the original cleartext.
|
byte[] |
encrypt(byte[] cleartext)
Encrypt the cleartext in byte array format.
|
byte[] |
encrypt(byte[] buffer,
int offset,
int length) |
protected void |
initDecryptCipher()
Initialize the ciphers used for encryption and decryption.
|
protected void |
initEncryptCipher()
Initialize the cipher used for encryption.
|
Object |
sealObject(Object object) |
void |
setClassLoader(ClassLoader classLoader) |
void |
setUseSealedObject(boolean useSealedObject) |
Object |
unsealObject(Object object) |
protected Key decryptKey
protected Cipher encryptCipher
Cipher
to use for encryption.protected String cipherAlgorithm
public static final String OLD_ENCRYPT_PREFIX
public static final String ENCRYPT_PREFIX
public BasicCryptor(Key encryptKey, Key decryptKey, String algorithm, IvParameterSpec iv) throws CryptoException
CryptoException
public void setUseSealedObject(boolean useSealedObject)
public void setClassLoader(ClassLoader classLoader)
public byte[] decrypt(byte[] ciphertext) throws CryptoException
decrypt
in interface Cryptor
ciphertext
- The text to be encrypted, in byte formCryptoException
protected void initDecryptCipher() throws CryptoException
CryptoException
public Object unsealObject(Object object) throws CryptoException
unsealObject
in interface Cryptor
CryptoException
public byte[] encrypt(byte[] cleartext) throws CryptoException
encrypt
in interface Cryptor
cleartext
- The text to be encrypted, in byte formCryptoException
public byte[] encrypt(byte[] buffer, int offset, int length) throws CryptoException
CryptoException
protected void initEncryptCipher() throws CryptoException
CryptoException
public Object sealObject(Object object) throws CryptoException
sealObject
in interface Cryptor
CryptoException
Copyright © 2020. All rights reserved.