mcrypt_get_iv_size()
(PHP 4 >= 4.0.2, PHP 5, PHP 7 < 7.2.0, PECL mcrypt >= 1.0.0)
返回指定算法/模式组合的初始向量大小
WarningThis function has beenDEPRECATEDas of PHP 7.1.0. Relying on this functionis highly discouraged.
说明
mcrypt_get_iv_size(string $cipher,string $mode): int
获取由$cipher/$mode参数指定的初始向量大小。
mcrypt_enc_get_iv_size()更加有用,因为它使用由mcrypt_module_open()返回的资源作为参数。
参数
- $cipher
MCRYPT_ciphername
常量中的一个,或者是字符串值的算法名称。- $mode
MCRYPT_MODE_modename
常量中的一个,或以下字符串中的一个:"ecb","cbc","cfb","ofb","nofb"和"stream"。由于 ECB 模式不使用初始向量,所以会忽略它。在加密和解密的过程中,你需要使用相同的初始向量(想象成:开始点)。
返回值
返回初始向量的大小,以字节为单位。如果发生错误,返回FALSE
。如果指定的算法/模式不需要初始向量,返回 0。
范例
mcrypt_get_iv_size()例程
<?php echo mcrypt_get_iv_size(MCRYPT_CAST_256, MCRYPT_MODE_CFB) . "\n"; echo mcrypt_get_iv_size('des', 'ecb') . "\n"; ?>
参见
mcrypt_get_block_size()
获得加密算法的分组大小mcrypt_enc_get_iv_size()
返回打开的算法的初始向量大小mcrypt_create_iv()
从随机源创建初始向量
The size of the initialization vector (iv) will be returned in bytes NOT bits, something to keep in mind specially if the iv is passed together appended or prepended with the encrypted data for decryption