title: RSA Encryption of Python List
body: <p>I am having troubling encrypting a Python list element by element. Each element is this list is a string. Here is my code:</p>
  <pre><code>from Crypto.PublicKey import RSA
  from Crypto.Cipher import PKCS1_OAEP
  
  #### Generate the public and private keys ####
  key = RSA.generate(1024, e=65537)
  priv_key = key.exportKey(&quot;PEM&quot;)
  public_key = key.publickey().exportKey(&quot;PEM&quot;)
  
  
  #Let's get some information!!
  firstName = input(&quot;Enter your First Name: &quot;) 
  lastName = input(&quot;Enter your Last Name: &quot;) 
  id = input(&quot;Enter your Personal ID: &quot;) 
  
  #list = [first_name, last_name, id]
  list = ['Bob', 'Dylan', '15898']
  listEncrypted = []
  
  #Now let's encrypt the list with a public key
  list_length = len(list)
  
  for index in range(list_length-1):
      cipher = PKCS1_OAEP.new(public_key)
      ciphertext = cipher.encrypt(list[index])
      listEncrypted.append(ciphertext)
  </code></pre>
  <p>The Error I am getting is:</p>
  <pre><code>  File &quot;C:\Users\moo\.spyder-py3\RSA.py&quot;, line 122, in &lt;module&gt;
    ciphertext = cipher.encrypt(list[index])
  
    File &quot;C:\Users\moo\anaconda3\lib\site-packages\Crypto\Cipher\PKCS1_OAEP.py&quot;, line 107, in encrypt
    modBits = Crypto.Util.number.size(self._key.n)
  
    AttributeError: 'bytes' object has no attribute 'n'
  </code></pre>
  <p>How do I encrypt the list using the user's input? Please help...</p>