<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.mcrypt.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.mcrypt-generic.php',
    1 => 'mcrypt_generic',
    2 => 'This function encrypts data',
  ),
  'up' => 
  array (
    0 => 'ref.mcrypt.php',
    1 => 'Mcrypt Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.mcrypt-encrypt.php',
    1 => 'mcrypt_encrypt',
  ),
  'next' => 
  array (
    0 => 'function.mcrypt-generic-deinit.php',
    1 => 'mcrypt_generic_deinit',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mcrypt/functions/mcrypt-generic.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.mcrypt-generic" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mcrypt_generic</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.2, PHP 5, PHP 7 &lt; 7.2.0, PECL mcrypt &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">mcrypt_generic</span> &mdash; <span class="dc-title">This function encrypts data</span></p>

 </div>
 <div id="function.mcrypt-generic-refsynopsisdiv">
  <div class="warning"><strong class="warning">Avviso</strong><p class="simpara">This function has been
<em>DEPRECATED</em> as of PHP 7.1.0 and
<em>REMOVED</em> as of PHP 7.2.0. Relying on this function
is highly discouraged.</p></div>
 </div>
 <div class="refsect1 description" id="refsect1-function.mcrypt-generic-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>mcrypt_generic</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$td</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$data</code></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="simpara">
   This function encrypts data. The data is padded with &quot;<code class="literal">\0</code>&quot;
   to make sure the length of the data is n * blocksize. This
   function returns the encrypted data. Note that the length
   of the returned string can in fact be longer than the input,
   due to the padding of the data.
  </p>
  <p class="simpara">
   If you want to store the encrypted data in a database make sure to store
   the entire string as returned by mcrypt_generic, or the string will not
   entirely decrypt properly.  If your original string is 10 characters long
   and the block size is 8 (use
   <span class="function"><a href="function.mcrypt-enc-get-block-size.php" class="function">mcrypt_enc_get_block_size()</a></span> to determine the
   blocksize), you would need at least 16 characters in your database field.
   Note the string returned by <span class="function"><a href="function.mdecrypt-generic.php" class="function">mdecrypt_generic()</a></span> will be
   16 characters as well...use rtrim($str, &quot;\0&quot;) to remove the padding.
  </p>
  <p class="simpara">
   If you are for example storing the data in a MySQL database remember that
   varchar fields automatically have trailing spaces removed during
   insertion. As encrypted data can end in a space (ASCII 32), the data will
   be damaged by this removal.  Store data in a tinyblob/tinytext (or
   larger) field instead.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mcrypt-generic-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <dl>
   
    <dt><code class="parameter">td</code></dt>
    <dd>
     <span class="simpara">
      The encryption descriptor.
     </span>
     <span class="simpara">
      The encryption handle should always be initialized with
      <span class="function"><a href="function.mcrypt-generic-init.php" class="function">mcrypt_generic_init()</a></span> with a key and an IV before
      calling this function. Where the encryption is done, you should free the
      encryption buffers by calling <span class="function"><a href="function.mcrypt-generic-deinit.php" class="function">mcrypt_generic_deinit()</a></span>.
      See <span class="function"><a href="function.mcrypt-module-open.php" class="function">mcrypt_module_open()</a></span> for an example.
     </span>
    </dd>
   
   
    <dt><code class="parameter">data</code></dt>
    <dd>
     <span class="simpara">
      The data to encrypt.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mcrypt-generic-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="simpara">
   Returns the encrypted data.
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.mcrypt-generic-seealso">
  <h3 class="title">Vedere anche:</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.mdecrypt-generic.php" class="function" rel="rdfs-seeAlso">mdecrypt_generic()</a> - Decrypts data</span></li>
   <li><span class="function"><a href="function.mcrypt-generic-init.php" class="function" rel="rdfs-seeAlso">mcrypt_generic_init()</a> - This function initializes all buffers needed for encryption</span></li>
   <li><span class="function"><a href="function.mcrypt-generic-deinit.php" class="function" rel="rdfs-seeAlso">mcrypt_generic_deinit()</a> - This function deinitializes an encryption module</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>