title: Python Blowfish Encryption
body: <p>I am struggling due to my incomplete knowledge of Java to convert this encryption code to Python code. The two should have the exact same results. Help would be greatly appreciated.</p>
  
  <p><em>Java Function</em></p>
  
  <pre><code>import javax.crypto.Cipher;
  import javax.crypto.spec.SecretKeySpec;
  import java.security.Key;
  
  
  class Main
  {
      public static void main (String[] args) throws java.lang.Exception
      {
          String s = "testings";
          Cipher cipher = Cipher.getInstance("Blowfish/ECB/PKCS5Padding");
          Key key = new SecretKeySpec("6#26FRL$ZWD".getBytes(), "Blowfish");
          cipher.init(1, key);
          byte[] enc_bytes = cipher.doFinal(s.getBytes());
          System.out.println(enc_bytes);
      }
  }
  </code></pre>
  
  <p><em>Python Equivalent</em></p>
  
  <pre><code>def PKCS5Padding(string):
      byteNum = len(string)
      packingLength = 8 - byteNum % 8
      if packingLength == 8:
          return string
      else:
          appendage = chr(packingLength) * packingLength
          return string + appendage
  
  def PandoraEncrypt(string):
      from Crypto.Cipher import Blowfish
      key = b'6#26FRL$ZWD'
      c1  = Blowfish.new(key, Blowfish.MODE_ECB)
      packedString = PKCS5Padding(string)
      return c1.encrypt(packedString)
  </code></pre>
  
  <p><strong>Results</strong></p>
  
  <p>Java Function: "??¾ô"</p>
  
  <p>Python Function: "Ë4A-¾`*ã"</p>