<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.hash.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.hash-hmac.php',
    1 => 'hash_hmac',
    2 => 'G&eacute;n&egrave;re une valeur de cl&eacute; de hachage en utilisant la m&eacute;thode HMAC',
  ),
  'up' => 
  array (
    0 => 'ref.hash.php',
    1 => 'hash_pbkdf2',
  ),
  'prev' => 
  array (
    0 => 'function.hash-hkdf.php',
    1 => 'hash_hkdf',
  ),
  'next' => 
  array (
    0 => 'function.hash-hmac-algos.php',
    1 => 'hash_hmac_algos',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/hash/functions/hash-hmac.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.hash-hmac" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">hash_hmac</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.2, PHP 7, PHP 8, PECL hash &gt;= 1.1)</p><p class="refpurpose"><span class="refname">hash_hmac</span> &mdash; <span class="dc-title">Génère une valeur de clé de hachage en utilisant la méthode HMAC</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.hash-hmac-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>hash_hmac</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$algo</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$data</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="attribute"><a href="class.sensitiveparameter.php">#[\SensitiveParameter]</a> </span><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$key</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$binary</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span><br>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>


 </div>

 <div class="refsect1 parameters" id="refsect1-function.hash-hmac-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">algo</code></dt>
     <dd>
      <p class="para">
       Nom de l&#039;algorithme de hachage sélectionné (par exemple : <code class="literal">&quot;sha256&quot;</code>).
       Pour une liste des algorithmes supportés voir <span class="function"><a href="function.hash-hmac-algos.php" class="function">hash_hmac_algos()</a></span>.
       <blockquote class="note"><p><strong class="note">Note</strong>: 
        <p class="para">
         Les fonctions de hachage non cryptographiques ne sont pas autorisées.
        </p>
       </p></blockquote>
      </p>
     </dd>
    
    
     <dt><code class="parameter">data</code></dt>
     <dd>
      <p class="para">
       Le message qui sera haché.
      </p>
     </dd>
    
    
     <dt><code class="parameter">key</code></dt>
     <dd>
      <p class="para">
       Clé secrète partagée utilisée pour générer la variance HMAC de
       l&#039;empreinte numérique.
      </p>
     </dd>
    
    
     <dt><code class="parameter">binary</code></dt>
     <dd>
      <p class="para">
       Lorsqu&#039;il vaut <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, la sortie sera des données brutes binaires.
       Lorsqu&#039;il vaut <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, la sortie sera des chiffres hexadécimaux en
       minuscule.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.hash-hmac-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Retourne une chaîne de caractères contenant l&#039;empreinte numérique calculée
   en chiffre hexadécimal minuscule à moins que
   <code class="parameter">binary</code> soit fixé à <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>. Dans ce cas, la
   représentation brute binaire de l&#039;empreinte numérique est retournée.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.hash-hmac-errors">
  <h3 class="title">Erreurs / Exceptions</h3>
  <p class="para">
   Lève une exception <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> si
   le paramètre <code class="parameter">algo</code> est inconnu ou n&#039;est
   pas une fonction de hachage cryptographique.
  </p>
 </div>

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

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.0.0</td>
       <td>
        <span class="function"><strong>hash_hmac()</strong></span> lance désormais une exception
        <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> si l&#039;<code class="parameter">algo</code>
        est inconnu ou n&#039;est pas une fonction de hachage cryptographique ;
        auparavant, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> était retourné à la place.
       </td>
      </tr>

      <tr>
       <td>7.2.0</td>
       <td>
        L&#039;utilisation de fonctions de hachage non cryptographiques (adler32, 
        crc32, crc32b, fnv132, fnv1a32, fnv164, fnv1a64, joaat) a été désactivée.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.hash-hmac-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <span class="function"><strong>hash_hmac()</strong></span></strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">hash_hmac</span><span style="color: #007700">(</span><span style="color: #DD0000">'sha256'</span><span style="color: #007700">, </span><span style="color: #DD0000">'The quick brown fox jumped over the lazy dog.'</span><span style="color: #007700">, </span><span style="color: #DD0000">'secret'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">9c5c42422b03f0ee32949920649445e417b2c634050833c5165704b825c2a53b</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.hash-hmac-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.hash-hmac-algos.php" class="function" rel="rdfs-seeAlso">hash_hmac_algos()</a> - Retourne la liste des algorithmes de hachage adapt&eacute;s pour hash_hmac</span></li>
    <li><span class="function"><a href="function.hash-hmac-file.php" class="function" rel="rdfs-seeAlso">hash_hmac_file()</a> - G&eacute;n&egrave;re une valeur de cl&eacute; de hachage en utilisant la m&eacute;thode HMAC et le contenu d'un fichier donn&eacute;</span></li>
    <li><span class="function"><a href="function.hash-equals.php" class="function" rel="rdfs-seeAlso">hash_equals()</a> - Comparaison de cha&icirc;nes r&eacute;sistante aux attaques temporelles</span></li>
   </ul>
  </p>
 </div>


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