<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="function.sodium-crypto-aead-xchacha20poly1305-ietf-encrypt">
 <refnamediv>
  <refname>sodium_crypto_aead_xchacha20poly1305_ietf_encrypt</refname>
  <refpurpose>(Preferred) Encrypt then authenticate with XChaCha20-Poly1305</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>string</type><methodname>sodium_crypto_aead_xchacha20poly1305_ietf_encrypt</methodname>
   <methodparam><type>string</type><parameter>message</parameter></methodparam>
   <methodparam><type>string</type><parameter>additional_data</parameter></methodparam>
   <methodparam><type>string</type><parameter>nonce</parameter></methodparam>
   <methodparam><type>string</type><parameter>key</parameter></methodparam>
  </methodsynopsis>
  <para>
   Encrypt then authenticate with XChaCha20-Poly1305 (eXtended-nonce variant).
  </para>
  <para>
   Generally, XChaCha20-Poly1305 is the best of the provided AEAD modes to use.
  </para>

 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <variablelist>
   <varlistentry>
    <term><parameter>message</parameter></term>
    <listitem>
     <para>
      The plaintext message to encrypt.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>additional_data</parameter></term>
    <listitem>
     <para>
      Additional, authenticated data. This is used in the verification of the authentication tag
      appended to the ciphertext, but it is not encrypted or stored in the ciphertext.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>nonce</parameter></term>
    <listitem>
     <para>
      A number that must be only used once, per message. 24 bytes long.
      This is a large enough bound to generate randomly (i.e. <function>random_bytes</function>).
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>key</parameter></term>
    <listitem>
     <para>
      Encryption key (256-bit).
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns the ciphertext and tag on success, &return.falseforfailure;.
  </para>
 </refsect1>


</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
