Package org.craftercms.commons.crypto
Class SimpleCipher
- java.lang.Object
-
- org.craftercms.commons.crypto.SimpleCipher
-
-
Field Summary
Fields Modifier and Type Field Description static StringERROR_KEY_DEC_ERRORstatic StringERROR_KEY_ENC_ERRORstatic StringERROR_KEY_IV_NOT_SETstatic StringERROR_KEY_KEY_NOT_SETstatic StringLOG_KEY_DEC_SUCCESSFULstatic StringLOG_KEY_DEF_CIPHER_CREATEDstatic StringLOG_KEY_ENC_SUCCESSFULstatic StringLOG_KEY_IV_GENstatic StringLOG_KEY_KEY_GEN
-
Constructor Summary
Constructors Constructor Description SimpleCipher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CiphercreateDefaultCipher()byte[]decrypt(byte[] encrypted)StringdecryptBase64(String encrypted)byte[]encrypt(byte[] clear)StringencryptBase64(String clear)CiphergetCipher()byte[]getIv()KeygetKey()voidsetCipher(Cipher cipher)voidsetIv(byte[] iv)voidsetKey(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()
-
-