<doc>
	<legacy_id>1252</legacy_id>
	<name>encrypt</name>
	<type>command</type>

	<syntax>
		<example>encrypt <i>source</i> using <i>cipher</i> with [password|key] <i>passorkey </i>[and salt saltvalue] [and IV <i>IVvalue</i>] [at <i>bitvalue</i> bit]</example>
	</syntax>

	<synonyms>
	</synonyms>

	<summary>Encrypt data using a cipher.</summary>

	<examples>
	</examples>

	<history>
		<introduced version="2.5">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>
		<function tag="cipherNames">cipherNames Function</function>
		<command tag="decrypt">decrypt Command</command>
		<property tag="sslcertificates">sslcertificates Property</property>
	</references>

	<description>
	<overview></overview>

		<parameters>
		</parameters>

	<value>On failure encrypt/decrypt set <b>the result</b> to the appropriate  ssl error message. On success the variable <i>it</i> will contain the  encrypted or decrypted data.</value>
	<comments>The encrypt and decrypt commands accept the source data that will be encrypted or decrypted. The cipher is the name of the cipher obtained using the ciphernames function. The passorkey specifies the password or key that will be use for encryption or decryption as determined by the keyword before it. If you specify key then the key needs to be the same size (in bits, eight per byte) as the specified cipher key length. The key may optionally be accompanied by the IVvalue used by some ciphers. If you specify password or don't specify a key mode, then a password, tyically text, will be used. The password may optionally be accompanied by a saltvalue. The bitvalue specifies the key length in bits (for example, 64, 128, 192 or 256) and may be zero or empty for the default length (that listed with the cipherNames function). Some ciphers have fixed key lengths and using an unsupported value will result in an error.<p></p><p>The key and IV value are the fundamental determiner in block ciphers. The IV value is typically the width (in bits) of the block associated with the cipher. The default value is zero. Its use is beyond the scope of this documentation.</p><p></p><p>The password and salt value are combined and scrambled to form the key and IV which are used as described above. mThe key derivation process is the same as that used in the openSSL utility. A 16-byte salt prefix is prepended to the encrypted data, based on the salt value. This is used in decryption. If no salt value is specified for a password, one is randomly generated. The use of a randomized salt value is a protection against dictionary attacks.</p><p></p><p>Some modes of block ciphers will pad data to be a multiple of block size. The padding method is that used by the openSSL utility and is a minimum of one byte.</p><p></p><p>To use OpenSSL functionality with LiveCode, make sure that the openssl shared library is installed, and in a place where LiveCode can find it. It is pre-installed with OSX. You can download and build OpenSSL at www.openssl.org and sitribute with your apps. LiveCode includes a prebuilt openssl dll which is required to use OpenSSL for windows (libeay32.dll) which needs to be in the application, current, or system directory. If LiveCode cannot load SSL, it will return the error in the result "ssl library not found".</p></comments>
	</description>
</doc>