title: Using PyCrypto to decrypt Perl encrypted password
body: <p>I'm trying to decrypt a pass phrase stored in a file.  The encryption was done with the Perl::CBC module, but I need to decrypt it for a Python script.  Frankly, I don't know much (or anything really) about encryption algorithms. </p>
  
  <p>The pass phrase was encrypted something like this:</p>
  
  <pre><code>use Crypt::CBC;
  
  my $key = '0123456789';
  my $iv  = '$KJh#(}q';
  
  my $cipher = Crypt::CBC-&gt;new(
      -key    =&gt; $key,
      -cipher =&gt; 'Blowfish',
      -header =&gt; 'none',
      -iv     =&gt; $iv,
  );
  
  my $passphrase = 'You have decrypted the passphrase.';
  my $hex_encrypted = $cipher-&gt;encrypt_hex($passphrase);
  </code></pre>
  
  <p>which gives an encrypted passphrase: 9033c838e4418fbdc50a9fc0813745296d195d59954008f94b2b36a8e65dca959686206960a7828a</p>
  
  <p>Now, I need to use this in a Python script (using Python 2.7). Naively, I was hoping this would work:</p>
  
  <pre><code>from Crypto.Cipher import Blowfish
  from binascii import hexlify, unhexlify
  
  perl_pass =  unhexlify('9033c838e4418fbdc50a9fc0813745296d195d59954008f94b2b36a8e65dca959686206960a7828a')
  key = '0123456789'
  iv  = '$KJh#(}q'
  print Blowfish.new(key, Blowfish.MODE_CBC, iv).decrypt(perl_pass)
  </code></pre>
  
  <p>but that only seems to create a bunch of unprintable junk.  I've played around a bit without success.  I'm not really sure what I need to do here to get this password decrypted successfully.</p>