BlowfishJ
Class BlowfishEasy
java.lang.Object
|
+--BlowfishJ.BlowfishEasy
- public class BlowfishEasy
- extends java.lang.Object
Support class for easy string encryption with the Blowfish algorithm,
now in CBC mode with a SHA-1 key setup and correct padding - the
purposes of this module is mainly to show a possible implementation
with Blowfish.
- Version:
- January 28, 2003
- Author:
- Markus Hahn
Constructor Summary |
BlowfishEasy(java.lang.String sPassword)
Constructor to set up a string as the key. |
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 (treated in Unicode). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BlowfishEasy
public BlowfishEasy(java.lang.String sPassword)
- Constructor to set up a string as the key.
- Parameters:
sPassword
- the password
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 (treated in Unicode).
- Parameters:
sPlainText
- string to encryptrndGen
- 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