<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.openssl.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.openssl-password-hash.php',
    1 => 'openssl_password_hash',
    2 => 'Cr&eacute;e un hachage de mot de passe en utilisant l\'impl&eacute;mentation Argon2 d\'OpenSSL',
  ),
  'up' => 
  array (
    0 => 'ref.openssl.php',
    1 => 'Fonctions OpenSSL',
  ),
  'prev' => 
  array (
    0 => 'function.openssl-open.php',
    1 => 'openssl_open',
  ),
  'next' => 
  array (
    0 => 'function.openssl-password-verify.php',
    1 => 'openssl_password_verify',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/openssl/functions/openssl-password-hash.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.openssl-password-hash" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">openssl_password_hash</h1>
  <p class="verinfo">(No version information available, might only be in Git)</p><p class="refpurpose"><span class="refname">openssl_password_hash</span> &mdash; <span class="dc-title">Crée un hachage de mot de passe en utilisant l&#039;implémentation Argon2 d&#039;OpenSSL</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.openssl-password-hash-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>openssl_password_hash</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$algo</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$password</code></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$options</code><span class="initializer"> = []</span></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   Crée un hachage de mot de passe en utilisant l&#039;implémentation Argon2
   d&#039;OpenSSL. Il s&#039;agit d&#039;une alternative à <span class="function"><a href="function.password-hash.php" class="function">password_hash()</a></span>
   qui utilise OpenSSL comme moteur, ce qui peut offrir une accélération
   matérielle sur certaines plateformes.
  </p>
  <p class="para">
   Cette fonction n&#039;est disponible que lorsque PHP est compilé avec le
   support OpenSSL incluant Argon2 (<code class="literal">HAVE_OPENSSL_ARGON2</code>).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.openssl-password-hash-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">algo</code></dt>
     <dd>
      <p class="para">
       L&#039;algorithme de hachage du mot de passe. Valeurs supportées :
       <code class="literal">&quot;argon2id&quot;</code> et <code class="literal">&quot;argon2i&quot;</code>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">password</code></dt>
     <dd>
      <p class="para">
       Le mot de passe de l&#039;utilisateur.
      </p>
     </dd>
    
    
     <dt><code class="parameter">options</code></dt>
     <dd>
      <p class="para">
       Un <a href="language.types.array.php" class="link">tableau</a> associatif d&#039;options. Clés supportées :
       <ul class="simplelist">
        <li>
         <code class="literal">memory_cost</code> : mémoire maximale (en Kio) pouvant
         être utilisée pour calculer le hachage
        </li>
        <li>
         <code class="literal">time_cost</code> : temps maximal pouvant être pris pour
         calculer le hachage
        </li>
        <li>
         <code class="literal">threads</code> : nombre de threads à utiliser pour
         calculer le hachage
        </li>
       </ul>
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.openssl-password-hash-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Retourne le hachage du mot de passe sous forme de <a href="language.types.string.php" class="link">chaîne de caractères</a>.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.openssl-password-hash-errors">
  <h3 class="title">Erreurs / Exceptions</h3>
  <p class="para">
   Lance une <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> si <code class="parameter">algo</code>
   n&#039;est pas l&#039;une des valeurs supportées
   (<code class="literal">&quot;argon2i&quot;</code> ou <code class="literal">&quot;argon2id&quot;</code>).
  </p>
  <p class="para">
   Lance une <span class="classname"><a href="class.error.php" class="classname">Error</a></span> si l&#039;opération de hachage échoue
   pour une raison inconnue.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.openssl-password-hash-changelog">
  <h3 class="title">Historique</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.4.0</td>
      <td>
       Ajout de la fonction.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.openssl-password-hash-examples">
  <h3 class="title">Exemples</h3>
  <div class="example" id="example-1">
   <p><strong>Exemple #1 Exemple avec <span class="function"><strong>openssl_password_hash()</strong></span></strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$hash </span><span style="color: #007700">= </span><span style="color: #0000BB">openssl_password_hash</span><span style="color: #007700">(</span><span style="color: #DD0000">'argon2id'</span><span style="color: #007700">, </span><span style="color: #DD0000">'mon-mot-de-passe-secret'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$hash</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>Résultat de l&#039;exemple ci-dessus est similaire à :</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">$argon2id$v=19$m=65536,t=4,p=1$c29tZXNhbHR2YWx1ZQ$hashvalue...</pre>
</div>
   </div>
  </div>
  <div class="example" id="example-2">
   <p><strong>Exemple #2 <span class="function"><strong>openssl_password_hash()</strong></span> avec des options personnalisées</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$hash </span><span style="color: #007700">= </span><span style="color: #0000BB">openssl_password_hash</span><span style="color: #007700">(</span><span style="color: #DD0000">'argon2id'</span><span style="color: #007700">, </span><span style="color: #DD0000">'mon-mot-de-passe-secret'</span><span style="color: #007700">, [<br />    </span><span style="color: #DD0000">'memory_cost' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">65536</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">'time_cost'   </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">4</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">'threads'     </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">1</span><span style="color: #007700">,<br />]);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.openssl-password-hash-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.openssl-password-verify.php" class="function" rel="rdfs-seeAlso">openssl_password_verify()</a> - V&eacute;rifie un mot de passe par rapport &agrave; un hachage en utilisant l'impl&eacute;mentation Argon2 d'OpenSSL</span></li>
    <li><span class="function"><a href="function.password-hash.php" class="function" rel="rdfs-seeAlso">password_hash()</a> - Cr&eacute;e une cl&eacute; de hachage pour un mot de passe</span></li>
   </ul>
  </p>
 </div>


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