|
SPT Core API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sptci.util.Encrypt
com.sptci.util.AESEncrypt
public class AESEncrypt
A utility class used to implement AES encryption and decryption of strings.
The following shows sample use of this class:
import com.sptci.util.AESEncrypt;
...
AESEncrypt aes = new AESEncrypt();
String secret = "my secret value";
String key = "my secret key";
byte[] encrypted = aes.encrypt( key, secret );
...
String mysecret = aes.decrypt( key, encrypted );
© Copyright 2007 Sans Pareil Technologies, Inc.
| Field Summary | |
|---|---|
protected static String |
ALGORITHM
The encryption algorithm to use to encrypt strings. |
protected static String |
SCHEME
The encryption scheme to use to encrypt strings. |
| Fields inherited from class com.sptci.util.Encrypt |
|---|
ENCODING, KEY_LENGTH, keyLength |
| Constructor Summary | |
|---|---|
AESEncrypt()
Default constructor. |
|
AESEncrypt(int length)
Designated constructor. |
|
| Method Summary | |
|---|---|
protected byte[] |
crypt(String key,
byte[] value,
int mode)
Encrypt/decrypt the specified value using the specified
key. |
| Methods inherited from class com.sptci.util.Encrypt |
|---|
decrypt, encrypt, getKey, handleException |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final String ALGORITHM
protected static final String SCHEME
| Constructor Detail |
|---|
public AESEncrypt()
Encrypt.KEY_LENGTH.
public AESEncrypt(int length)
length - The length of the key to use for encryption and decryption| Method Detail |
|---|
protected byte[] crypt(String key,
byte[] value,
int mode)
throws InvalidKeyException,
BadPaddingException,
RuntimeException
value using the specified
key.
crypt in class Encryptkey - The key to use to encrypt the value.value - The value that is to be encrypted or decrypted.mode - The operation mode of this cipher (this is one of the
following: Cipher.ENCRYPT_MODE, Cipher.DECRYPT_MODE, Cipher.WRAP_MODE or Cipher.UNWRAP_MODE).
InvalidKeyException - If the given key is inappropriate for
initializing the Cipher, or its keysize exceeds the
maximum allowable keysize (as determined from the configured jurisdiction
policy files).
BadPaddingException - Declared in underlying implementation but never
raised in this method.
RuntimeException - If IllegalBlockSizeException,
NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException are raised while
encrypting or decrypting.Encrypt.getKey(java.lang.String)
|
SPT Core API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||