|
JSecurity | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jsecurity.crypto.BlowfishCipher
public class BlowfishCipher
JSecurity's default symmetric block Cipher using the Blowfish algorithm. As it is a symmetric Cipher, it uses the
same Key to both encrypt and decrypt data. If one is not provided via the setKey method,
a default one will be used, BUT NOTE:
Because JSecurity is an open-source project, if anyone knew that you were using JSecurity's default
Key, they could download/view the source, and with enough effort, reconstruct the Key
and decode encrypted data at will.
JSecurity only really uses Ciphers to encrypt user ids and session ids, so if that information is not critical to you and you think the default key still makes things 'sufficiently difficult', then you can ignore this issue.
However, if you do feel this constitutes sensitive information, it is recommended that you provide your own
Key via the setKey method to a Key known only to your application,
guaranteeing that no third party can decrypt your data. If you want to know how to do this, you can browse this
class's source code for the generateNewKey() method to see how we created our default. Then you can
duplicate the same in your environment and set the result on an instance of this class via the
setKey method.
| Constructor Summary | |
|---|---|
BlowfishCipher()
|
|
| Method Summary | |
|---|---|
protected byte[] |
crypt(byte[] bytes,
int mode,
byte[] key)
|
protected byte[] |
crypt(Cipher cipher,
byte[] bytes)
|
byte[] |
decrypt(byte[] encrypted,
byte[] key)
Decrypts encrypted data via the specified Cipher key and returns the original (pre-encrypted) data. |
byte[] |
encrypt(byte[] raw,
byte[] key)
Encrypts data via the specified Cipher key. |
static Key |
generateNewKey()
|
static Key |
generateNewKey(int keyBitSize)
|
Key |
getKey()
|
protected void |
init(Cipher cipher,
int mode,
Key key)
|
static void |
main(String[] unused)
|
protected Cipher |
newCipherInstance()
|
void |
setKey(Key key)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BlowfishCipher()
| Method Detail |
|---|
public Key getKey()
public void setKey(Key key)
public byte[] encrypt(byte[] raw,
byte[] key)
Cipher
encrypt in interface Cipherraw - the data to encryptkey - the Cipher key used during encryption.
public byte[] decrypt(byte[] encrypted,
byte[] key)
Cipher
decrypt in interface Cipherencrypted - the previously encrypted data to decryptkey - the Cipher key used during decryption.
protected Cipher newCipherInstance()
protected void init(Cipher cipher,
int mode,
Key key)
protected byte[] crypt(Cipher cipher,
byte[] bytes)
protected byte[] crypt(byte[] bytes,
int mode,
byte[] key)
public static Key generateNewKey()
public static Key generateNewKey(int keyBitSize)
public static void main(String[] unused)
throws Exception
Exception
|
JSecurity | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||