Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<sodium_crypto_aead_xchacha20poly1305_ietf_keygensodium_crypto_auth_keygen>
^Sodium FunctionsLast updated: Mon, 26 Oct 2026

sodium_crypto_auth

(PHP 7 >= 7.2.0, PHP 8)

sodium_crypto_auth — Compute a tag for the message

Description

function sodium_crypto_auth(string $message, #[\SensitiveParameter] string $key): string

Symmetric message authentication via sodium_crypto_auth() provides integrity, but not confidentiality.

Unlike with digital signatures (e.g. sodium_crypto_sign_detached()), any party capable of verifying a message is also capable of authenticating their own messages. (Hence, symmetric authentication.)

Parameters

message

The message you intend to authenticate

key

Authentication key

Return Values

Authentication tag


<sodium_crypto_aead_xchacha20poly1305_ietf_keygensodium_crypto_auth_keygen>
^Sodium FunctionsLast updated: Mon, 26 Oct 2026