<?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-stream-xchacha20-xor-ic.php',
    1 => 'sodium_crypto_stream_xchacha20_xor_ic',
    2 => 'Chiffre un message en utilisant un nonce et une cl&eacute; secr&egrave;te (sans authentification)',
  ),
  'up' => 
  array (
    0 => 'ref.sodium.php',
    1 => 'Sodium Fonctions',
  ),
  'prev' => 
  array (
    0 => 'function.sodium-crypto-stream-xchacha20-xor.php',
    1 => 'sodium_crypto_stream_xchacha20_xor',
  ),
  'next' => 
  array (
    0 => 'function.sodium-crypto-stream-xor.php',
    1 => 'sodium_crypto_stream_xor',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/sodium/functions/sodium-crypto-stream-xchacha20-xor-ic.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.sodium-crypto-stream-xchacha20-xor-ic" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">sodium_crypto_stream_xchacha20_xor_ic</h1>
  <p class="verinfo">(PHP 8 &gt;= 8.2.0)</p><p class="refpurpose"><span class="refname">sodium_crypto_stream_xchacha20_xor_ic</span> &mdash; <span class="dc-title">Chiffre un message en utilisant un nonce et une clé secrète (sans authentification)</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.sodium-crypto-stream-xchacha20-xor-ic-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>sodium_crypto_stream_xchacha20_xor_ic</strong></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">$message</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">$nonce</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$counter</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>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="simpara">
   Cette fonction est similaire à <span class="function"><a href="function.sodium-crypto-stream-xchacha20-xor.php" class="function">sodium_crypto_stream_xchacha20_xor()</a></span>
   mais ajoute la possibilité de définir la valeur initiale du compteur de blocs à une valeur non nulle.
   Cela permet d&#039;accéder directement à n&#039;importe quel bloc sans avoir à calculer les précédents.
  </p>

  <div class="caution"><strong class="caution">Attention</strong>
   <p class="simpara">
    Ce chiffrement est non authentifié, et ne prévient pas les attaques par texte chiffré choisi.
    Il faut s&#039;assurer de combiner le texte chiffré avec un code d&#039;authentification de message,
    par exemple avec la fonction <span class="function"><a href="function.sodium-crypto-aead-xchacha20poly1305-ietf-encrypt.php" class="function">sodium_crypto_aead_xchacha20poly1305_ietf_encrypt()</a></span>,
    ou <span class="function"><a href="function.sodium-crypto-auth.php" class="function">sodium_crypto_auth()</a></span>.
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.sodium-crypto-stream-xchacha20-xor-ic-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <dl>
   
    <dt><code class="parameter">message</code></dt>
    <dd>
     <span class="simpara">
      Le message à chiffrer.
     </span>
    </dd>
   
   
    <dt><code class="parameter">nonce</code></dt>
    <dd>
     <span class="simpara">
      Un nonce de 24 octets.
     </span>
    </dd>
   
   
    <dt><code class="parameter">counter</code></dt>
    <dd>
     <span class="simpara">
      La valeur initiale du compteur de blocs.
     </span>
    </dd>
   
   
    <dt><code class="parameter">key</code></dt>
    <dd>
     <span class="simpara">
      Clé, possiblement générée par la fonction <span class="function"><a href="function.sodium-crypto-stream-xchacha20-keygen.php" class="function">sodium_crypto_stream_xchacha20_keygen()</a></span>.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.sodium-crypto-stream-xchacha20-xor-ic-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="simpara">
   Le texte chiffré, ou  ou <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si une erreur survient.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.sodium-crypto-stream-xchacha20-xor-ic-examples">
  <h3 class="title">Exemples</h3>
  <div class="example" id="example-1">
   <p><strong>Exemple #1 Exemple de <span class="function"><strong>sodium_crypto_stream_xchacha20_xor_ic()</strong></span></strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$n2 </span><span style="color: #007700">= </span><span style="color: #0000BB">random_bytes</span><span style="color: #007700">(</span><span style="color: #0000BB">SODIUM_CRYPTO_STREAM_XCHACHA20_NONCEBYTES</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$left  </span><span style="color: #007700">= </span><span style="color: #0000BB">str_repeat</span><span style="color: #007700">(</span><span style="color: #DD0000">"\x01"</span><span style="color: #007700">, </span><span style="color: #0000BB">64</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$right </span><span style="color: #007700">= </span><span style="color: #0000BB">str_repeat</span><span style="color: #007700">(</span><span style="color: #DD0000">"\xfe"</span><span style="color: #007700">, </span><span style="color: #0000BB">64</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Tout en une fois :<br /></span><span style="color: #0000BB">$stream7_unified </span><span style="color: #007700">= </span><span style="color: #0000BB">sodium_crypto_stream_xchacha20_xor</span><span style="color: #007700">(</span><span style="color: #0000BB">$left </span><span style="color: #007700">. </span><span style="color: #0000BB">$right</span><span style="color: #007700">, </span><span style="color: #0000BB">$n2</span><span style="color: #007700">, </span><span style="color: #0000BB">$key</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Par morceaux, avec un compteur initial :<br /></span><span style="color: #0000BB">$stream7_left  </span><span style="color: #007700">= </span><span style="color: #0000BB">sodium_crypto_stream_xchacha20_xor_ic</span><span style="color: #007700">(</span><span style="color: #0000BB">$left</span><span style="color: #007700">, </span><span style="color: #0000BB">$n2</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">$key</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$stream7_right </span><span style="color: #007700">= </span><span style="color: #0000BB">sodium_crypto_stream_xchacha20_xor_ic</span><span style="color: #007700">(</span><span style="color: #0000BB">$right</span><span style="color: #007700">, </span><span style="color: #0000BB">$n2</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">$key</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$stream7_concat </span><span style="color: #007700">= </span><span style="color: #0000BB">$stream7_left </span><span style="color: #007700">. </span><span style="color: #0000BB">$stream7_right</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$stream7_concat</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$stream7_unified </span><span style="color: #007700">=== </span><span style="color: #0000BB">$stream7_concat</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">int(128)
bool(true)</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.sodium-crypto-stream-xchacha20-xor-ic-seealso">
  <h3 class="title">Voir aussi</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.sodium-crypto-stream-xchacha20-xor.php" class="function" rel="rdfs-seeAlso">sodium_crypto_stream_xchacha20_xor()</a> - Chiffre une donn&eacute;e en utilisant un nonce et une cl&eacute; secr&egrave;te (sans authentification)</span></li>
  </ul>
 </div>


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