php-doc-en/reference/mcrypt/functions/mcrypt-create-iv.xml
Torben Wilson af4410a7e1 Normalized the sgml-default-dtd-file local-variable line for those
still using this, after discussion on the phpdoc list.
From now on, manual.ced will need to be found at ~/.phpdoc/manual.ced.



git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@288721 c90b9560-bf6c-de11-be94-00142212c4b1
2009-09-25 07:04:39 +00:00

123 lines
3.7 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<refentry xml:id="function.mcrypt-create-iv" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>mcrypt_create_iv</refname>
<refpurpose>Create an initialization vector (IV) from a random source</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<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><initializer>MCRYPT_DEV_RANDOM</initializer></methodparam>
</methodsynopsis>
<para>
Create an initialization vector (IV) from a random source.
</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
losing security.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>size</parameter></term>
<listitem>
<para>
Determines the size of the IV, parameter <parameter>source</parameter>
(defaults to random value) specifies the source of the IV.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>source</parameter></term>
<listitem>
<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>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the initialization vector, or &false; on error.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<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>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><link xlink:href="&url.mcrypt.iv;">&url.mcrypt.iv;</link></member>
<member><link xlink:href="&url.mcrypt.bcm;">&url.mcrypt.bcm;</link></member>
<member>Chapter 9.3 of Applied Cryptography by Schneier (ISBN 0-471-11709-9)</member>
</simplelist>
</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:"~/.phpdoc/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
-->