PHP Conference Japan 2024

sodium_crypto_stream_xchacha20_xor

(PHP 8 >= 8.1.0)

sodium_crypto_stream_xchacha20_xor使用 nonce 和密鑰加密訊息(無驗證)

說明

sodium_crypto_stream_xchacha20_xor(#[\SensitiveParameter] 字串 $message, 字串 $nonce, #[\SensitiveParameter] 字串 $key): 字串

使用 nonce 和密鑰加密訊息(無驗證)。

警告

此加密方法未經身份驗證,且無法防止選擇密文攻擊。請務必將密文與訊息鑑別碼 (MAC) 結合使用,例如使用 sodium_crypto_aead_xchacha20poly1305_ietf_encrypt() 函式,或 sodium_crypto_auth() 函式。

參數

message

要加密的訊息。

nonce

24 位元組的 nonce。

key

密鑰,可能由 sodium_crypto_stream_xchacha20_keygen() 產生。

回傳值

已加密的訊息。

參見

新增註釋

使用者貢獻的註釋

此頁面沒有使用者貢獻的註釋。
To Top