array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.openssl-decrypt.php', 1 => 'openssl_decrypt', ), 'up' => array ( 0 => 'ref.openssl.php', 1 => 'OpenSSL 函数', ), 'prev' => array ( 0 => 'function.openssl-csr-sign.php', 1 => 'openssl_csr_sign', ), 'next' => array ( 0 => 'function.openssl-dh-compute-key.php', 1 => 'openssl_dh_compute_key', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/openssl/functions/openssl-decrypt.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
openssl_decrypt — 解密数据
$data
,$cipher_algo
,$passphrase
,$options
= 0,$iv
= "",$tag
= null
,$aad
= ""采用原始或base64编码的字符串,并使用给定的方法和密钥对其进行解密。
data
将被解密的密文。
cipher_algo
加密算法,使用openssl_get_cipher_methods()函数获取可用的加密算法列表。
passphrase
密钥。
options
options
can be one of
OPENSSL_RAW_DATA
,
OPENSSL_ZERO_PADDING
.
iv
非空的初始化向量。
tag
AEAD密码模式中的身份验证标签。 如果是错误的,验证失败,函数返回false
.
函数不检查 tag
的长度。调用者有责任确保 tag 的长度与调用 openssl_encrypt()
时检索到的 tag 的长度相匹配。否则,如果给定的 tag 仅匹配正确 tag 的开头,解密可能会成功。
aad
额外的认证数据。
成功时已解密的字符串 或者在失败时返回 false
。
版本 | 说明 |
---|---|
8.1.0 | tag 现在可为 null。 |
7.1.0 | 添加了 tag 和 aad 参数。 |