title: Printing RSA Decrypted byte string with Crypto?
body: <p>I have these sequence of commands through the shell that work fine:</p>
  
  <pre><code>fishgills@fishgills-Mac  ~  cat /tmp/secret_message
  Helloo there.%
  fishgills@fishgills-Mac  ~  openssl rsautl -encrypt -inkey ~/Documents/test_pub.pem  -pubin -in /tmp/secret_message -out /tmp/test.enc
  fishgills@fishgills-Mac  ~  openssl rsautl -decrypt -inkey ~/Documents/test.pem -in /tmp/test.enc
  Helloo there.%
  fishgills@fishgills-Mac  ~ 
  </code></pre>
  
  <p>As you can see, everything works fine. Encrypt the message and is able to decrypt it.</p>
  
  <p>So in python, I'm trying to do the same:</p>
  
  <pre><code>from Crypto.PublicKey import RSA
  
  rsakey = RSA.importKey(open("/Users/fishgills/Documents/test.pem", 'rb').read())
  raw_data = open("/tmp/test.enc", 'rb').read()
  decrypted = rsakey.decrypt(raw_data)
  print decrypted
  </code></pre>
  
  <p>And the program's output is:</p>
  
  <pre><code>fishgills@fishgills-Mac  ~  python main.py ~/Documents/test.pem
  �%��u�9��炿��:og:_�Z��WF/��W �v��������a�Jw+�J�Th�N9`V���5t##Go0�
  #��A2e*����a�����a�ň��ߘhQX��U�7AB��B�Q�X�l��    ����rkK����� �kKj��\u���PILT�@���Rj���0:��߰9˕�Helloo there.
  </code></pre>
  
  <p>You can see the message in there... but there's a pile of junk. PyCrypto documentation says that the <code>decrypt</code> method returns a byte string but I haven't been able to <code>decode</code> it properly, I get things like:</p>
  
  <pre><code>Traceback (most recent call last):
    File "main.py", line 9, in &lt;module&gt;
      print decrypted.decode("utf-8")
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.py", line 16, in decode
      return codecs.utf_8_decode(input, errors, True)
  UnicodeDecodeError: 'utf8' codec can't decode byte 0xd7 in position 1: invalid continuation byte
  </code></pre>
  
  <p>Anyone able to point me in the right direction?</p>