title: How to encrypt a large file in openssl using public key
body: <p>How can I encrypt a large file  with a public key so that no one other than who has the private key be able to decrypt it?</p>
  
  <p>I can make RSA public and private keys but when it comes to encrypting a large file using this command:</p>
  
  <pre><code>openssl rsautl -encrypt -pubin -inkey public.pem -in myLargeFile.xml -out myLargeFile_encrypted.xml
  </code></pre>
  
  <p>and how can i perform the decryption also....</p>
  
  <p>i create my private and public key by the following commands</p>
  
  <pre><code>openssl genrsa -out private.pem 1024
  openssl rsa -in private.pem -out public.pem -outform PEM -pubout
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>RSA operation error
  3020:error:0406D06E:rsa routines:RSA_padding_add_PKCS1_type_2:data too large for key size:.\crypto\rsa\rsa_pk1.c:151:
  </code></pre>
  
  <p>I tried to make keys with sizes from 1024 to 1200 bits, no luck, same error</p>