php-doc-en/reference/mcrypt/functions/mcrypt-create-iv.xml
Hannes Magnusson c030e2adf7 Upgrade to DocBook5:
- All id attributes are now xml:id
 - Add docbook namespace to all root elements
 - Replace <ulink /> with <link xlink:href />
 - Minor markup fixes here and there


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@238160 c90b9560-bf6c-de11-be94-00142212c4b1
2007-06-20 22:25:43 +00:00

94 lines
3.2 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.10 $ -->
<!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 -->
<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>
<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
losing security.
</para>
<para>
More information can be found at <link
xlink:href="&url.mcrypt.iv;">&url.mcrypt.iv;</link>, <link
xlink:href="&url.mcrypt.bcm;">&url.mcrypt.bcm;</link> 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
-->