org.gregoire.util.crypto
Class BlowfishEasy

java.lang.Object
  extended byorg.gregoire.util.crypto.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:
September 21, 2002
Author:
Markus Hahn

Constructor Summary
BlowfishEasy(java.lang.String sPassword)
          constructor to set up a string as the key (oversized password will be cut)
 
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 standard Java random generator, which isn't that great for creating IVs
 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
 

Constructor Detail

BlowfishEasy

public BlowfishEasy(java.lang.String sPassword)
constructor to set up a string as the key (oversized password will be cut)

Parameters:
sPassword - the password (treated as a real unicode array)
Method Detail

encryptString

public java.lang.String encryptString(java.lang.String sPlainText)
encrypts a string (treated in UNICODE) using the standard Java random generator, which isn't that great for creating IVs

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 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 © Paul Gregoire, All Rights Reserved.