|
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
public abstract class Encrypt
Abstract base class of all classes that implement common encryption routins.
© Copyright 2007 Sans Pareil Technologies, Inc.
| Field Summary | |
|---|---|
static String |
ENCODING
The default encoding to use to convert between strings and bytes. |
static int |
KEY_LENGTH
The length of the key used to encrypt the password. |
protected int |
keyLength
The length of the keys used by this instance for encryption and decryption. |
| Constructor Summary | |
|---|---|
protected |
Encrypt()
Creates a new instance of Encrypt |
protected |
Encrypt(int length)
Designated constructor. |
| Method Summary | |
|---|---|
protected abstract byte[] |
crypt(String key,
byte[] value,
int mode)
Encrypt/decrypt the specified value using the specified
key. |
String |
decrypt(String key,
byte[] value)
Decrypt the specified value using the specified
key. |
byte[] |
encrypt(String key,
String value)
Encrypt the specified value using the specified
key. |
protected byte[] |
getKey(String key)
Return a cleaned up key based on the specified key. |
protected RuntimeException |
handleException(Throwable throwable)
Throw a RuntimeException wrapping the specified throwable. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int KEY_LENGTH
public static final String ENCODING
protected final int keyLength
| Constructor Detail |
|---|
protected Encrypt()
protected Encrypt(int length)
length - The length of the key to use for encryption and decryption| Method Detail |
|---|
public byte[] encrypt(String key,
String value)
throws InvalidKeyException,
BadPaddingException,
RuntimeException
value using the specified
key.
key - The key to use to encrypt the value.value - The value that is to be encrypted.
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 are raised while encrypting.crypt(java.lang.String, byte[], int)
public String decrypt(String key,
byte[] value)
throws InvalidKeyException,
BadPaddingException,
RuntimeException
value using the specified
key.
key - The key to use to decrypt the value.value - The value that is to be decrypted.
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 - If (un)padding has been requested, but the
decrypted data is not bounded by the appropriate padding bytes.
RuntimeException - If IllegalBlockSizeException,
NoSuchPaddingException, NoSuchAlgorithmException are raised while decrypting.crypt(java.lang.String, byte[], int)protected byte[] getKey(String key)
key. Ensure
that the returned key is of the requisite length for the
encryption scheme.
key - The key that is to be corrected if necessary.
key to use as a byte array.
RuntimeException - If UnsupportedEncodingException is raised on
converting corrected key to ENCODING.protected RuntimeException handleException(Throwable throwable)
RuntimeException wrapping the specified throwable.
throwable - The throwable instance that is to be wrapped.
throwable.
protected abstract byte[] crypt(String key,
byte[] value,
int mode)
throws InvalidKeyException,
BadPaddingException,
RuntimeException
value using the specified
key.
key - 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 are raised while encrypting or
decrypting.
|
SPT Core API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||