<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.sodium.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.sodium-crypto-generichash-init.php',
    1 => 'sodium_crypto_generichash_init',
    2 => 'Initialise un hachage pour le streaming',
  ),
  'up' => 
  array (
    0 => 'ref.sodium.php',
    1 => 'Sodium Fonctions',
  ),
  'prev' => 
  array (
    0 => 'function.sodium-crypto-generichash-final.php',
    1 => 'sodium_crypto_generichash_final',
  ),
  'next' => 
  array (
    0 => 'function.sodium-crypto-generichash-keygen.php',
    1 => 'sodium_crypto_generichash_keygen',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/sodium/functions/sodium-crypto-generichash-init.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.sodium-crypto-generichash-init" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">sodium_crypto_generichash_init</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.2.0, PHP 8)</p><p class="refpurpose"><span class="refname">sodium_crypto_generichash_init</span> &mdash; <span class="dc-title">Initialise un hachage pour le streaming</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.sodium-crypto-generichash-init-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>sodium_crypto_generichash_init</strong></span>(<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 class="initializer"> = &quot;&quot;</span></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$length</code><span class="initializer"> = <strong><code><a href="sodium.constants.php#constant.sodium-crypto-generichash-bytes">SODIUM_CRYPTO_GENERICHASH_BYTES</a></code></strong></span></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="simpara">
   La méthode d&#039;initialisation pour l&#039;API de hachage générique en streaming.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.sodium-crypto-generichash-init-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <dl>
   
    <dt><code class="parameter">key</code></dt>
    <dd>
     <span class="simpara">
      La clé de hachage générique.
     </span>
    </dd>
   
   
    <dt><code class="parameter">length</code></dt>
    <dd>
     <span class="simpara">
      La taille de la sortie attendue de la fonction de hachage.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.sodium-crypto-generichash-init-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="simpara">
   Renvoie un état de hachage, sérialisé sous forme d&#039;une chaîne binaire brute.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.sodium-crypto-generichash-init-examples">
  <h3 class="title">Exemples</h3>
  <div class="example" id="sodium-crypto-generichash-init.example.basic">
   <p><strong>Exemple #1 Exemple de <span class="function"><strong>sodium_crypto_generichash_init()</strong></span></strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$messages </span><span style="color: #007700">= [</span><span style="color: #0000BB">random_bytes</span><span style="color: #007700">(</span><span style="color: #0000BB">32</span><span style="color: #007700">), </span><span style="color: #0000BB">random_bytes</span><span style="color: #007700">(</span><span style="color: #0000BB">32</span><span style="color: #007700">), </span><span style="color: #0000BB">random_bytes</span><span style="color: #007700">(</span><span style="color: #0000BB">16</span><span style="color: #007700">)];<br /></span><span style="color: #0000BB">$state </span><span style="color: #007700">= </span><span style="color: #0000BB">sodium_crypto_generichash_init</span><span style="color: #007700">(</span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #0000BB">32</span><span style="color: #007700">);<br />foreach (</span><span style="color: #0000BB">$messages </span><span style="color: #007700">as </span><span style="color: #0000BB">$message</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">sodium_crypto_generichash_update</span><span style="color: #007700">(</span><span style="color: #0000BB">$state</span><span style="color: #007700">, </span><span style="color: #0000BB">$message</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">$final </span><span style="color: #007700">= </span><span style="color: #0000BB">sodium_crypto_generichash_final</span><span style="color: #007700">(</span><span style="color: #0000BB">$state</span><span style="color: #007700">, </span><span style="color: #0000BB">32</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">sodium_bin2hex</span><span style="color: #007700">(</span><span style="color: #0000BB">$final</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$allAtOnce </span><span style="color: #007700">= </span><span style="color: #0000BB">sodium_crypto_generichash</span><span style="color: #007700">(</span><span style="color: #0000BB">implode</span><span style="color: #007700">(</span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #0000BB">$messages</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">sodium_bin2hex</span><span style="color: #007700">(</span><span style="color: #0000BB">$allAtOnce</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">string(64) &quot;a2939a9163cb7c796ec28e01028489e72475c136b2697ea59e3e760ab4a8ab20&quot;
string(64) &quot;a2939a9163cb7c796ec28e01028489e72475c136b2697ea59e3e760ab4a8ab20&quot;</pre>
</div>
   </div>
  </div>
 </div>


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