codecamp

PHP8 sodium_crypto_aead_aes256gcm_encrypt

(PHP 7 >= 7.2.0, PHP 8)

sodium_crypto_aead_aes256gcm_encrypt — 加密然后使用 AES-256-GCM 进行身份验证

说明

sodium_crypto_aead_aes256gcm_encrypt(
    string $message,
    string $additional_data,
    string $nonce,
    string $key
): string

加密,然后使用 AES-256-GCM 进行身份验证。 仅当 sodium_crypto_aead_aes256gcm_is_available() 返回 true 时才可用。

参数 

message

要加密的明文消息。

additional_data

其他经过身份验证的数据。这用于验证身份验证标记 附加到密文中,但未加密或存储在密文中。

nonce

每封邮件只能使用一次的号码。长度为 12 个字节。

key

加密密钥(256 位)。

返回值 

以原始二进制字节字符串的形式返回密文和身份验证标记。(格式:密文,然后是标签。


PHP8 sodium_crypto_aead_aes256gcm_decrypt
PHP8 sodium_crypto_aead_aes256gcm_is_available
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定