(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 起移除。強烈建議不要使用本函數。
$cipher
,$key
,$data
,$mode
,$iv
= ?
解密 data
并返回明文。
cipher
MCRYPT_ciphername
常量中的一個(gè),或者是字符串值的算法名稱(chēng)。
key
數據加密密鑰。
如果密鑰長(cháng)度不是加解密算法能夠支持的有效長(cháng)度,
那么會(huì )產(chǎn)生警告并且返回 false
data
要使用給定的 cipher
和
mode
解密的數據。
如果數據大小不是 n * 分組大小,則在其后追加 '\0
' 來(lái)補齊。
mode
MCRYPT_MODE_modename
常量中的一個(gè),或以下字符串中的一個(gè):"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
.
以字符串格式返回解密后的數據, 或者在失敗時(shí)返回 false
。
版本 | 說(shuō)明 |
---|---|
5.6.0 |
不再接受無(wú)效長(cháng)度的 key and iv 參數。
如果參數長(cháng)度無(wú)效,則 mcrypt_decrypt() 函數會(huì )產(chǎn)生警告并且返回 false 。
之前版本中,對于長(cháng)度不足的密鑰和初始向量會(huì )在其后補齊 '\0 '
使其達到有效長(cháng)度。
|