函数名:sodium_crypto_secretstream_xchacha20poly1305_push()
适用版本:PHP 7.2.0及以上
函数用法:该函数用于将消息数据加密并追加到一个密文流中。
语法:sodium_crypto_secretstream_xchacha20poly1305_push(resource $stream, string $msg [, string $ad = "" [, int $tag = SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_MESSAGE]]): string|false
参数:
返回值:
示例:
// 创建密文流
$stream = sodium_crypto_secretstream_xchacha20poly1305_init_push($key);
// 要加密的消息数据
$message = "Hello, World!";
// 加密消息并追加到密文流中
$cipher = sodium_crypto_secretstream_xchacha20poly1305_push($stream, $message);
// 打印加密后的密文数据
echo bin2hex($cipher);
注意事项: