Package org.craftercms.commons.crypto
Class SimpleCipher
- java.lang.Object
-
- org.craftercms.commons.crypto.SimpleCipher
-
-
Field Summary
Fields Modifier and Type Field Description static String
ERROR_KEY_DEC_ERROR
static String
ERROR_KEY_ENC_ERROR
static String
ERROR_KEY_IV_NOT_SET
static String
ERROR_KEY_KEY_NOT_SET
static String
LOG_KEY_DEC_SUCCESSFUL
static String
LOG_KEY_DEF_CIPHER_CREATED
static String
LOG_KEY_ENC_SUCCESSFUL
static String
LOG_KEY_IV_GEN
static String
LOG_KEY_KEY_GEN
-
Constructor Summary
Constructors Constructor Description SimpleCipher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Cipher
createDefaultCipher()
byte[]
decrypt(byte[] encrypted)
String
decryptBase64(String encrypted)
byte[]
encrypt(byte[] clear)
String
encryptBase64(String clear)
Cipher
getCipher()
byte[]
getIv()
Key
getKey()
void
setCipher(Cipher cipher)
void
setIv(byte[] iv)
void
setKey(Key key)
-
-
-
Field Detail
-
LOG_KEY_ENC_SUCCESSFUL
public static final String LOG_KEY_ENC_SUCCESSFUL
- See Also:
- Constant Field Values
-
LOG_KEY_DEC_SUCCESSFUL
public static final String LOG_KEY_DEC_SUCCESSFUL
- See Also:
- Constant Field Values
-
LOG_KEY_KEY_GEN
public static final String LOG_KEY_KEY_GEN
- See Also:
- Constant Field Values
-
LOG_KEY_IV_GEN
public static final String LOG_KEY_IV_GEN
- See Also:
- Constant Field Values
-
LOG_KEY_DEF_CIPHER_CREATED
public static final String LOG_KEY_DEF_CIPHER_CREATED
- See Also:
- Constant Field Values
-
ERROR_KEY_KEY_NOT_SET
public static final String ERROR_KEY_KEY_NOT_SET
- See Also:
- Constant Field Values
-
ERROR_KEY_IV_NOT_SET
public static final String ERROR_KEY_IV_NOT_SET
- See Also:
- Constant Field Values
-
ERROR_KEY_ENC_ERROR
public static final String ERROR_KEY_ENC_ERROR
- See Also:
- Constant Field Values
-
ERROR_KEY_DEC_ERROR
public static final String ERROR_KEY_DEC_ERROR
- See Also:
- Constant Field Values
-
-
Method Detail
-
getKey
public Key getKey()
-
setKey
public void setKey(Key key)
-
getIv
public byte[] getIv()
-
setIv
public void setIv(byte[] iv)
-
getCipher
public Cipher getCipher()
-
setCipher
public void setCipher(Cipher cipher)
-
encryptBase64
public String encryptBase64(String clear) throws CryptoException
- Throws:
CryptoException
-
encrypt
public byte[] encrypt(byte[] clear) throws CryptoException
- Throws:
CryptoException
-
decryptBase64
public String decryptBase64(String encrypted) throws CryptoException
- Throws:
CryptoException
-
decrypt
public byte[] decrypt(byte[] encrypted) throws CryptoException
- Throws:
CryptoException
-
createDefaultCipher
protected Cipher createDefaultCipher()
-
-