<doc>
	<legacy_id></legacy_id>
	<name>encrypt using rsa</name>
	<type>command</type>

	<syntax>
		<example>encrypt <i>source</i> using rsa with {public | private} key <i>key</i> [and passphrase <i>passphrase</i>]</example>
	</syntax>

	<synonyms>
	</synonyms>

	<summary>Encrypt data using the RSA algorithm.</summary>

	<examples>
<example>encrypt myMessage with public key myKey</example>
<example>encrypt thisMessage with private key privateKey</example>
	</examples>

	<history>
		<introduced version="4.6">Added.</introduced>
		<deprecated version=""></deprecated>
		<removed version=""></removed>
		
		<experimental version=""></experimental>
		<nonexperimental version=""></nonexperimental>
	</history>

	<objects>
	</objects>

	<platforms>
		<mac/>
		<windows/>
		<linux/>
		<ios/>
		<android/>
	</platforms>

	<classes>
		<desktop/>
		<server/>
		<web/>
		<mobile/>
	</classes>

	<security>
		<network/>
	</security>


	<classification>
	</classification>

	<references>
		<command tag="decrypt">decrypt Command</command>
		<command tag="encrypt">encrypt Command</command>
		<command tag="decrypt using rsa">decrypt using rsa Command</command>
	</references>

	<description>
	<overview>Use the <b>encrypt using rsa</b> command to encrypt a message using RSA public key encryption.</overview>

		<parameters>
  <parameter>The <i>message</i> is the message to be encrypted</parameter>
  <parameter>The <i>key</i> is the key to be used for the encryption, in PEM format</parameter>
  <parameter>The <i>passphrase </i>is an optional passphrase</parameter>		</parameters>

	<value></value>
	<comments>Use the form <p><b>&#9;</b>encrypt <i>message</i> with public key <i>key</i></p><p>to encode a message that you only want to be decoded by the holder of the private key.</p><p></p><p>Use the form </p><p>&#9;encrypt <i>message</i> with private key <i>key</i></p><p>to encode a message that a receiver can then verify has come from one of the holders of the private key (this is a signing operation).</p><p></p><p><b>Generating key pairs</b></p><p>Public-private key pairs can be generated using the OpenSSL suite of command-line tools. For example:</p><p>&#9;openssl genrsa -out private_key.pem 512</p><p>&#9;openssl rsa -pubout -in private_key.pem -out public_key.pem</p><p>Will generate a key pair of size 512-bits, placing the private key in private_key.pem and the public key in public_key.pem.</p><p></p><p>For more information on these utilities see http://www.openssl.org/docs/apps/rsa.html and http://www.openssl.org/docs/apps/genrsa.html.</p><p></p><p></p><p></p><note> The maximum length of a message that can be encrypted using RSA is the size of the key in bytes -11. So, for a 512-bit key pair, the maximum encryptable message size is 53 bytes.</note><p></p><p>For signing, the maximum length of an encryptable message isn't really an issue since typically in that scenario it will be some sort of hash that would be being encrypted. For the more traditional encrypting scenario, however, the standard approach is to use public key cryptography to encrypt a random password which is then used with a symmetric cipher to actually encrypt the payload.</p></comments>
	</description>
</doc>