public class CryptorBase extends java.lang.Object implements Cryptor
Constructor and Description |
---|
CryptorBase() |
CryptorBase(javax.crypto.Cipher cipher,
javax.crypto.spec.SecretKeySpec keySpec,
javax.crypto.spec.IvParameterSpec ivSpec) |
Modifier and Type | Method and Description |
---|---|
byte[] |
decrypt(byte[] data) |
java.lang.String |
decrypt(java.lang.String str) |
byte[] |
encrypt(byte[] data) |
java.lang.String |
encrypt(java.lang.String str) |
static byte[] |
generateKeyFromPassphrase(java.lang.String passphrase)
Create an AES key from a SHA-2 hash of a passphrase
|
void |
setHexKey(java.lang.String hexKey) |
void |
setIV(byte[] bytes)
Sets initialization vector for algorithm
|
void |
setIV(byte[] bytes,
int len)
Sets initialization vector for algorithm with a given
length.
|
void |
setIV(javax.crypto.spec.IvParameterSpec ivSpec)
Sets initialization vector for algorithm
|
void |
setIV(java.lang.String iv64)
Sets initialization vector
|
void |
setIVHex(java.lang.String ivHex)
Sets initialization vector
|
void |
setKey(byte[] key) |
void |
setKey(java.lang.String base64key) |
void |
setKeyFromPassphrase(java.lang.String passphrase) |
public CryptorBase()
public CryptorBase(javax.crypto.Cipher cipher, javax.crypto.spec.SecretKeySpec keySpec, javax.crypto.spec.IvParameterSpec ivSpec)
public void setKey(byte[] key)
public void setKey(java.lang.String base64key) throws java.lang.Exception
java.lang.Exception
public void setHexKey(java.lang.String hexKey) throws java.lang.Exception
java.lang.Exception
public void setKeyFromPassphrase(java.lang.String passphrase)
public static byte[] generateKeyFromPassphrase(java.lang.String passphrase)
passphrase
- string describing the passphrasepublic void setIV(javax.crypto.spec.IvParameterSpec ivSpec)
ivSpec
- initialization vectorpublic void setIV(byte[] bytes)
bytes
- initialization vector as bytespublic void setIV(byte[] bytes, int len)
bytes
- initialization vector as byteslen
- length of the vectorpublic void setIV(java.lang.String iv64)
iv64
- base64-encoded bytespublic void setIVHex(java.lang.String ivHex)
ivHex
- base16-encoded bytespublic java.lang.String encrypt(java.lang.String str)
public java.lang.String decrypt(java.lang.String str)