Results 1 to 1 of 1
  1. #1
    Neo Angelus is offline Member
    Join Date
    Jun 2010
    Rep Power

    Default 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
    Java Code:
      md5_key =
      payload = (md5_key + cleartext)
      secret_key = "XXXXX_XXXXXX_XXXXXX+" + password
      return, 1).encrypt(payload)
    And tried it with this code:
    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);
    		return cipher.doFinal(inputText.getBytes());
    Java Code:
    	public static String md5(String to) throws Exception{
    	    MessageDigest m = MessageDigest.getInstance("MD5");
    	    return m.digest();
    But I ran into the following two problems:
    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?

    The password variable is 7 characters long.
    Last edited by Neo Angelus; 06-08-2010 at 07:12 PM. Reason: Fixed md5

Similar Threads

  1. Blowfish encryption
    By Gustavo in forum Advanced Java
    Replies: 0
    Last Post: 04-14-2010, 09:38 PM
  2. Jython : python for java
    By cotarelo in forum New To Java
    Replies: 1
    Last Post: 03-25-2010, 09:53 AM
  3. Call java Methods from Python Script
    By hofsoc in forum New To Java
    Replies: 1
    Last Post: 02-18-2009, 05:47 PM
  4. Calling Java methods form Python
    By mew in forum Advanced Java
    Replies: 1
    Last Post: 12-21-2007, 03:30 PM
  5. Encryption in java
    By Ed in forum Advanced Java
    Replies: 1
    Last Post: 07-09-2007, 01:47 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts