<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.xpass.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.crypt-gensalt.php',
    1 => 'crypt_gensalt',
    2 => 'Compile a string for use as the salt argument to crypt',
  ),
  'up' => 
  array (
    0 => 'ref.xpass.php',
    1 => 'Xpass Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.crypt-checksalt.php',
    1 => 'crypt_checksalt',
  ),
  'next' => 
  array (
    0 => 'function.crypt-preferred-method.php',
    1 => 'crypt_preferred_method',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/xpass/functions/crypt-gensalt.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.crypt-gensalt" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">crypt_gensalt</h1>
  <p class="verinfo">(PECL xpass &gt;= 1.1.0)</p><p class="refpurpose"><span class="refname">crypt_gensalt</span> &mdash; <span class="dc-title">Compile a string for use as the salt argument to crypt</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.crypt-gensalt-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>crypt_gensalt</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$prefix</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$count</code><span class="initializer"> = 0</span></span>): <span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span></div>

  <p class="simpara">
   Compile a string for use as the salt argument to <span class="function"><a href="function.crypt.php" class="function">crypt()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.crypt-gensalt-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <dl>
   
    <dt><code class="parameter">prefix</code></dt>
    <dd>
     <span class="simpara">
      Hashing method.
      One of the <strong><code><a href="xpass.constants.php#constant.crypt-prefix-std-des">CRYPT_PREFIX_<span class="replaceable">*</span></a></code></strong> constant.
      If <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, the best available hashing method will be selected.
     </span>
    </dd>
   
   
    <dt><code class="parameter">count</code></dt>
    <dd>
     <span class="simpara">
      Controls the processing cost of the hash;
      the valid range and exact meaning of count depend on the hashing method,
      but larger numbers correspond to more costly hashes in
      terms of CPU time and possibly memory usage.
      If count is <code class="literal">0</code>, a low default cost will be selected.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.crypt-gensalt-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="simpara">
   Returns a string with the setting, or <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> in case of an error.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.crypt-gensalt-examples">
  <h3 class="title">Esempi</h3>
  <div class="example" id="example-1">
   <p><strong>Example #1 A <span class="function"><strong>crypt_gensalt()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Generate the salt<br /></span><span style="color: #0000BB">$salt </span><span style="color: #007700">= </span><span style="color: #0000BB">crypt_gensalt</span><span style="color: #007700">(</span><span style="color: #0000BB">CRYPT_PREFIX_BLOWFISH</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// Hash the password<br /></span><span style="color: #0000BB">$hash </span><span style="color: #007700">= </span><span style="color: #0000BB">crypt</span><span style="color: #007700">(</span><span style="color: #DD0000">"secret"</span><span style="color: #007700">, </span><span style="color: #0000BB">$salt</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// Check the hash<br /></span><span style="color: #0000BB">$test </span><span style="color: #007700">= </span><span style="color: #0000BB">hash_equals</span><span style="color: #007700">(</span><span style="color: #0000BB">crypt</span><span style="color: #007700">(</span><span style="color: #DD0000">"secret"</span><span style="color: #007700">, </span><span style="color: #0000BB">$hash</span><span style="color: #007700">), </span><span style="color: #0000BB">$hash</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$salt</span><span style="color: #007700">, </span><span style="color: #0000BB">$hash</span><span style="color: #007700">, </span><span style="color: #0000BB">$test</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>Il precedente esempio visualizzerà:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">string(29) &quot;$2y$05$GcPykP.Am8C1.dGamdpwW.&quot;
string(60) &quot;$2y$05$GcPykP.Am8C1.dGamdpwW.1RR.7uicWvJPZfJfCEizZHqVWwuaJLm&quot;
bool(true)</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.crypt-gensalt-seealso">
  <h3 class="title">Vedere anche:</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.crypt-preferred-method.php" class="function" rel="rdfs-seeAlso">crypt_preferred_method()</a> - Get the prefix of the preferred hash method</span></li>
   <li><span class="function"><a href="function.crypt.php" class="function" rel="rdfs-seeAlso">crypt()</a> - Criptazione di una stringa a senso unico (hashing)</span></li>
   <li><span class="function"><a href="function.hash-equals.php" class="function" rel="rdfs-seeAlso">hash_equals()</a> - Timing attack safe string comparison</span></li>
  </ul>
 </div>


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