title: Python RSA encryption
body: <p>I am trying to write a RSA encryption software tool that will use the same key every single time. here is what I have so far.</p>
  
  <pre><code>import Crypto
  from Crypto.PublicKey import RSA
  from Crypto import Random
  
  key = &lt;_RSAobj @0x24b6348 n&lt;1024&gt;,e,d,p,q,u,private&gt;
  publickey = key.publickey()
  encrypted = publickey.encrypt('hi', 32)
  print(encrypted)
  </code></pre>
  
  <p>I get a syntax error at line 5 pointing at the &lt; sign. I know that this is a valid private key. what is the problem and how do I fix it. Also I am using python 2.7.3</p>
  
  <p>[EDIT] I get the key from this code</p>
  
  <pre><code>import Crypto
  from Crypto.PublicKey import RSA
  from Crypto import Random
  import os
  random_generator = Random.new().read
  key = RSA.generate(1024, random_generator)
  print(key)
  raw_input()
  </code></pre>
  
  <p>Also I am getting a 'RSA key format not supported error' from this code after the 'raw_input()'</p>
  
  <pre><code>import Crypto
  from Crypto.PublicKey import RSA
  from Crypto import Random
  text_file = open("keyfile.txt", "w")
  text_file.write('&lt;_RSAobj @0x24b6348 n&lt;1024&gt;,e,d,p,q,u,private&gt;')
  text_file.close()
  raw_input()
  with open('keyfile.txt', 'r') as f:
      externKey = f.readline()
  key = RSA.importKey(externKey, passphrase=None)
  publickey = key.publickey()
  encrypted = publickey.encrypt('hi', 32)
  print(encrypted)
  </code></pre>