<?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.8 $ --> <!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 --> <refentry id="function.mcrypt-create-iv"> <refnamediv> <refname>mcrypt_create_iv</refname> <refpurpose> Create an initialization vector (IV) from a random source </refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>string</type><methodname>mcrypt_create_iv</methodname> <methodparam><type>int</type><parameter>size</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>source</parameter></methodparam> </methodsynopsis> <para> <function>mcrypt_create_iv</function> is used to create an IV. </para> <para> Parameter <parameter>size</parameter> determines the size of the IV, parameter <parameter>source</parameter> (defaults to random value) specifies the source of the IV. </para> <para> The source can be <constant>MCRYPT_RAND</constant> (system random number generator), <constant>MCRYPT_DEV_RANDOM</constant> (read data from <filename>/dev/random</filename>) and <constant>MCRYPT_DEV_URANDOM</constant> (read data from <filename>/dev/urandom</filename>). <constant>MCRYPT_RAND</constant> is the only one supported on Windows because Windows (of course) doesn't have <filename>/dev/random</filename> or <filename>/dev/urandom</filename>. </para> <note> <para> When using <constant>MCRYPT_RAND</constant>, remember to call <function>srand</function> before <function>mcrypt_create_iv</function> to initialize the random number generator; it is not seeded automatically like <function>rand</function> is. </para> </note> <para> <example> <title><function>mcrypt_create_iv</function> example</title> <programlisting role="php"> <![CDATA[ <?php $size = mcrypt_get_iv_size(MCRYPT_CAST_256, MCRYPT_MODE_CFB); $iv = mcrypt_create_iv($size, MCRYPT_DEV_RANDOM); ?> ]]> </programlisting> </example> </para> <para> The IV is only meant to give an alternative seed to the encryption routines. This IV does not need to be secret at all, though it can be desirable. You even can send it along with your ciphertext without loosing security. </para> <para> More information can be found at <ulink url="&url.mcrypt.iv;">&url.mcrypt.iv;</ulink>, <ulink url="&url.mcrypt.bcm;">&url.mcrypt.bcm;</ulink> and in chapter 9.3 of Applied Cryptography by Schneier (ISBN 0-471-11709-9) for a discussion of this topic. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->