Results 1 to 1 of 1
- 06-08-2010, 04:38 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 1
- Rep Power
- 0
Java Blowfish port from Python(Encryption)
Greetings everyone,
I have a question concerning encryption and porting code from Python.
I wanted to port the following code from Python:
Java Code:from Crypto.Cipher import Blowfish from Crypto.Hash import MD5
And tried it with this code:Java Code:md5_key = MD5.new(cleartext).digest() payload = (md5_key + cleartext) secret_key = "XXXXX_XXXXXX_XXXXXX+" + password return Blowfish.new(secret_key, 1).encrypt(payload)
Java Code:byte[] secret_key = ("XXXXX_XXXXXX_XXXXXX+" + password).getBytes(); SecretKey secretkey = new SecretKeySpec(secret_key, "Blowfish"); Cipher cipher = Cipher.getInstance("Blowfish"); cipher.init(Cipher.ENCRYPT_MODE, secretkey); cipher.update(md5(inputText)); return cipher.doFinal(inputText.getBytes());But I ran into the following two problems:Java Code:public static String md5(String to) throws Exception{ MessageDigest m = MessageDigest.getInstance("MD5"); m.update(to.getBytes(),0,to.length()); return m.digest(); }
Fixed: The md5 payload doesn't match.(I outputted both payloads and compared them.)
Using blowfish I get: Illegal key size or default parameters
To be honest I'm completely lost. I've tried to fix it all afternoon, but I couldn't fix them.
Could someone please help me?
btw,
The password variable is 7 characters long.Last edited by Neo Angelus; 06-08-2010 at 07:12 PM. Reason: Fixed md5
Similar Threads
-
Blowfish encryption
By Gustavo in forum Advanced JavaReplies: 0Last Post: 04-14-2010, 09:38 PM -
Jython : python for java
By cotarelo in forum New To JavaReplies: 1Last Post: 03-25-2010, 08:53 AM -
Call java Methods from Python Script
By hofsoc in forum New To JavaReplies: 1Last Post: 02-18-2009, 04:47 PM -
Calling Java methods form Python
By mew in forum Advanced JavaReplies: 1Last Post: 12-21-2007, 02:30 PM -
Encryption in java
By Ed in forum Advanced JavaReplies: 1Last Post: 07-09-2007, 01:47 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks