mcrypt_get_key_size()
(PHP 4, 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_key_size(int $cipher): int
mcrypt_get_key_size(string $cipher,string $mode): int
第一个原型是针对 libmcrypt 2.2.x 的,第二个原型是针对 libmcrypt 2.4.x 或 2.5.x 的。
mcrypt_get_key_size()用来获取由$cipher所指定的算法和模式所需的密钥长度。
mcrypt_enc_get_key_size()更加有用,因为它使用由mcrypt_module_open()返回的资源。
参数
- $cipher
MCRYPT_ciphername
常量中的一个,或者是字符串值的算法名称。- $mode
MCRYPT_MODE_modename
常量中的一个,或以下字符串中的一个:"ecb","cbc","cfb","ofb","nofb"和"stream"。
返回值
返回算法所支持的最大密钥大小,以字节为单位。或者在失败时返回FALSE
。
范例
mcrypt_get_key_size()例程
<?php echo mcrypt_get_key_size('tripledes', 'ecb'); ?>
在 libmcrypt 2.4.x 或 2.5.x 版本中,如果使用本函数。
以上例程会输出:
24
参见
mcrypt_get_block_size()
获得加密算法的分组大小mcrypt_enc_get_key_size()
返回打开的模式所能支持的最长密钥mcrypt_encrypt()
使用给定参数加密明文
While not specified in the description, this function, just like mcrypt_enc_get_key_size(), returns the cipher's largest key size in BYTES.