net.sourceforge.blowfishj
Class BlowfishEasy

java.lang.Object
  extended bynet.sourceforge.blowfishj.BlowfishEasy

public class BlowfishEasy
extends java.lang.Object

Support class for easy string encryption with the Blowfish algorithm. Works in CBC mode with a SHA-1 key setup and correct padding - the purpose of this class is mainly to show a possible implementation with Blowfish.


Constructor Summary
BlowfishEasy(char[] passw)
          Constructor to use string data as the key.
BlowfishEasy(java.lang.String sPassword)
          Deprecated. use the BlowfishEasy(char[]) instead, since this constructor discards the higher 8 bits of every 16bit Unicode character; be aware that this constructor will produce non-compatible results to the new method!
 
Method Summary
 java.lang.String decryptString(java.lang.String sCipherText)
          Decrypts a hexbin string (handling is case sensitive).
 void destroy()
          Destroys (clears) the encryption engine, after that the instance is not valid anymore.
 java.lang.String encryptString(java.lang.String sPlainText)
          Encrypts a string (treated in Unicode) using the internal random generator.
 java.lang.String encryptString(java.lang.String sPlainText, java.util.Random rndGen)
          Encrypts a string (in Unicode).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlowfishEasy

public BlowfishEasy(java.lang.String sPassword)
Deprecated. use the BlowfishEasy(char[]) instead, since this constructor discards the higher 8 bits of every 16bit Unicode character; be aware that this constructor will produce non-compatible results to the new method!

Constructor to set up a string as the key.

Parameters:
sPassword - the password

BlowfishEasy

public BlowfishEasy(char[] passw)
Constructor to use string data as the key.

Parameters:
passw - the password, usually gained by String.toCharArray()
Method Detail

encryptString

public java.lang.String encryptString(java.lang.String sPlainText)
Encrypts a string (treated in Unicode) using the internal random generator.

Parameters:
sPlainText - string to encrypt
Returns:
encrypted string in binhex format

encryptString

public java.lang.String encryptString(java.lang.String sPlainText,
                                      java.util.Random rndGen)
Encrypts a string (in Unicode).

Parameters:
sPlainText - string to encrypt
rndGen - random generator (usually a java.security.SecureRandom instance)
Returns:
encrypted string in binhex format

decryptString

public java.lang.String decryptString(java.lang.String sCipherText)
Decrypts a hexbin string (handling is case sensitive).

Parameters:
sCipherText - hexbin string to decrypt
Returns:
decrypted string (null equals an error)

destroy

public void destroy()
Destroys (clears) the encryption engine, after that the instance is not valid anymore.



Copyright © 2004-2005 Sourceforge. All Rights Reserved.