函数:sodium_crypto_secretstream_xchacha20poly1305_init_pull()
适用版本:PHP 7.2.0+
用法: sodium_crypto_secretstream_xchacha20poly1305_init_pull(string $header, string $key): string|false
参数:
返回值:
示例:
<?php
$encryptedHeader = '...'; // 加密流的头部信息
$secretKey = '...'; // 密钥
$stream = sodium_crypto_secretstream_xchacha20poly1305_init_pull($encryptedHeader, $secretKey);
if ($stream === false) {
die('初始化解密流失败');
}
// 解密流的进一步操作
?>
注意事项:
libsodium扩展。sodium_crypto_secretstream_xchacha20poly1305_init_push()函数生成加密流的头部信息。sodium_crypto_secretstream_xchacha20poly1305_keygen()函数生成一个随机的密钥。sodium_crypto_secretstream_xchacha20poly1305_pull()函数来解密具体的数据块。