<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.mcrypt-generic-init" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>mcrypt_generic_init</refname>
  <refpurpose>This function initializes all buffers needed for encryption</refpurpose>
 </refnamediv>
 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>int</type><methodname>mcrypt_generic_init</methodname>
   <methodparam><type>resource</type><parameter>td</parameter></methodparam>
   <methodparam><type>string</type><parameter>key</parameter></methodparam>
   <methodparam><type>string</type><parameter>iv</parameter></methodparam>
  </methodsynopsis>
  <para>
   You need to call this function before every call to
   <function>mcrypt_generic</function> or
   <function>mdecrypt_generic</function>.
  </para>
 </refsect1>
 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>td</parameter></term>
     <listitem>
      <para>
       The encryption descriptor.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>key</parameter></term>
     <listitem>
      <para>
       The maximum length of the key should be the one obtained by calling
       <function>mcrypt_enc_get_key_size</function> and every value smaller
       than this is legal.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>iv</parameter></term>
     <listitem>
      <para>
       The IV should normally have the size of the algorithms block size, but
       you must obtain the size by calling
       <function>mcrypt_enc_get_iv_size</function>. IV is ignored in ECB. IV
       MUST exist in CFB, CBC, STREAM, nOFB and OFB modes. It needs to be
       random and unique (but not secret). The same IV must be used for
       encryption/decryption. If you do not want to use it you should set it
       to zeros, but this is not recommended.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>
 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   The function returns a negative value on error, -3 when the key length
   was incorrect, -4 when there was a memory allocation problem and any
   other return value is an unknown error. If an error occurs a warning will
   be displayed accordingly. &false; is returned if incorrect parameters
   were passed.
  </para>
 </refsect1>
 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>mcrypt_module_open</function></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
-->