public class BlowfishEncrypt extends Encrypt
The following shows sample use of this class:
import com.sptci.util.BlowfishEncrypt;
...
BlowfishEncrypt bf = new BlowfishEncrypt();
String secret = "my secret value";
String key = "my secret key";
byte[] encrypted = bf.encrypt( key, secret );
...
String mysecret = bf.decrypt( key, encrypted );
© Copyright 2007 Sans Pareil Technologies, Inc.
| Modifier and Type | Field and Description |
|---|---|
protected static String |
ALGORITHM
The encryption algorithm to use to encrypt strings.
|
protected static String |
SCHEME
The encryption scheme to use to encrypt strings.
|
ENCODING, KEY_LENGTH, keyLength| Constructor and Description |
|---|
BlowfishEncrypt()
Default constructor.
|
BlowfishEncrypt(int length)
Designated constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
crypt(String key,
byte[] value,
int mode)
Encrypt/decrypt the specified
value using the specified
key. |
protected static final String ALGORITHM
protected static final String SCHEME
public BlowfishEncrypt()
Encrypt.KEY_LENGTH.public BlowfishEncrypt(int length)
length - The length of the key to use for encryption and decryptionprotected 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 are raised while encrypting or
decrypting.Encrypt.getKey(java.lang.String)