mcrypt_decrypt

(PHP 4 >= 4.0.2, PHP 5, PHP 7 < 7.2.0, PECL mcrypt >= 1.0.0)

mcrypt_decrypt使用给定参数解密密文

警告

本函数已自 PHP 7.1.0 起废弃并将自 PHP 7.2.0 起移除。强烈建议不要使用本函数。

说明

mcrypt_decrypt ( string $cipher , string $key , string $data , string $mode , string $iv = ? ) : string

解密 data 并返回明文。

参数

cipher

MCRYPT_ciphername 常量中的一个,或者是字符串值的算法名称。

key

数据加密密钥。 如果密钥长度不是加解密算法能够支持的有效长度, 那么会产生警告并且返回 false

data

要使用给定的 ciphermode 解密的数据。 如果数据大小不是 n * 分组大小,则在其后追加 '\0' 来补齐。

mode

MCRYPT_MODE_modename 常量中的一个,或以下字符串中的一个:"ecb","cbc","cfb","ofb","nofb" 和 "stream"。

iv

Used for the initialization in CBC, CFB, OFB modes, and in some algorithms in STREAM mode. If the provided IV size is not supported by the chaining mode or no IV was provided, but the chaining mode requires one, the function will emit a warning and return false.

返回值

以字符串格式返回解密后的数据, 或者在失败时返回 false

更新日志

版本 说明
5.6.0 不再接受无效长度的 key and iv 参数。 如果参数长度无效,则 mcrypt_decrypt() 函数会产生警告并且返回 false。 之前版本中,对于长度不足的密钥和初始向量会在其后补齐 '\0' 使其达到有效长度。

参见