public class AESCrypter extends java.lang.Object implements Crypter
Modifier and Type | Class and Description |
---|---|
static class |
AESCrypter.KeySize |
Modifier and Type | Field and Description |
---|---|
static AESCrypter.KeySize |
AES128 |
static AESCrypter.KeySize |
AES192 |
static AESCrypter.KeySize |
AES256 |
Constructor and Description |
---|
AESCrypter() |
AESCrypter(byte[] key) |
AESCrypter(java.lang.String hexKey) |
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,
AESCrypter.KeySize keySize) |
AESCrypter.KeySize |
getKeySize() |
void |
setKey(byte[] key) |
void |
setKey(java.lang.String hexKey) |
void |
setKeyFromPassphrase(java.lang.String passphrase) |
boolean |
setKeySize(AESCrypter.KeySize keySize)
Sets the key size, in number of bytes
|
public static final AESCrypter.KeySize AES256
public static final AESCrypter.KeySize AES192
public static final AESCrypter.KeySize AES128
public AESCrypter()
public AESCrypter(java.lang.String hexKey) throws java.lang.Exception
java.lang.Exception
public AESCrypter(byte[] key) throws java.lang.Exception
java.lang.Exception
public boolean setKeySize(AESCrypter.KeySize keySize)
keySize
- either 16 or 32public AESCrypter.KeySize getKeySize()
public void setKey(byte[] key) throws java.lang.Exception
java.lang.Exception
public void setKey(java.lang.String hexKey) throws java.lang.Exception
java.lang.Exception
public void setKeyFromPassphrase(java.lang.String passphrase) throws java.lang.Exception
java.lang.Exception
public static byte[] generateKeyFromPassphrase(java.lang.String passphrase, AESCrypter.KeySize keySize)
public java.lang.String encrypt(java.lang.String str) throws java.lang.Exception
public java.lang.String decrypt(java.lang.String str) throws java.lang.Exception
public byte[] encrypt(byte[] data) throws java.lang.Exception