• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to use blowfish  RSS feed

 
aakil
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I wanted to use blowfish to encrypt a text file before saving it. I later want to decrypt it too.
I downloaded blowfish from the authors site
http://www.schneier.com/
when I try to compile Blowfish.java it does not recognise
import java.security.Cipher
and
import java.security.SymmetricCipher
Do I need any other classes/api's. I am using jdk "1.4.2_01"
I would really appreciate it if any gurus show the code peice to encrypt and decrypt a string
 
aakil
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since I couldnt wake any of you gurus, I went back to the site and downloaded twofish-java.zip. Thought I would try Twofish instead of Blowfish. Ofcourse I have no clue if I could just encrypt a string using this. This file contained two files Twofish_Algorithm.java and Twofish_Properties.java. The compilation was OK this time.
but I could not figure out how to encrypt a string. My requirement is to encrypt a string and save it to a file, later I need to decrypt the string reading from the file.
it contained a method
"blockEncrypt (byte[] in, int inOffset, Object sessionKey)"
it says
/**
* Encrypt exactly one block of plaintext.
*
* @param in The plaintext.
* @param inOffset Index of in from which to start considering data.
* @param sessionKey The session key to use for encryption.
* @return The ciphertext generated from a plaintext using the session key.
*/
I tried to give these input values
in : myMsg.getBytes()
inOffset: 0
sessionKey: I din know what to give so I gave a string like "64" I guessed it should take a string since it expects an object
but compiling my class reports that
Exception in thread "main" java.lang.ClassCastException" on the method call line
This time I am moving towards a brick wall, dear gurus pls wake up and guide me thru some code :roll:
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if we could see the code that you actually USED it would help.
Here is the TwoFish Manual, which might help.
I am moving this to "Other API's".
 
aakil
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you sheriff
I missed
Object key = fish.makeKey(keyCode);
for session key while trying the code.
I thought since session key param was an object even string would be OK.
That was the mistake.
I had done the code successfully
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!