(PHP 7 >= 7.2.0,PHP 8)
sodium_crypto_aead_xchacha20poly1305_ietf_decrypt — (偏好)使用 XChaCha20-Poly1305 驗證然後解密
$ciphertext
,$additional_data
,$nonce
,$key
使用 ChaCha20-Poly1305 (擴展 nonce 變體) 驗證然後解密。
一般來說,XChaCha20-Poly1305 是提供的 AEAD 模式中最好使用的。
ciphertext
必須為 sodium_crypto_aead_chacha20poly1305_ietf_encrypt() 提供的格式 (密文和標籤,串連)。
additional_data
額外的、經過驗證的資料。這用於驗證附加到密文的驗證標籤,但不會加密或儲存在密文中。
nonce
每個訊息只能使用一次的數字。長度為 24 個位元組。這是一個足夠大的範圍來隨機生成 (例如 random_bytes())。
key
加密金鑰 (256 位元)。
成功時傳回明文,失敗時傳回 false
。