mcrypt_get_block_size
(PHP 4, PHP 5, PHP 7 < 7.2.0, PECL mcrypt >= 1.0.0)
mcrypt_get_block_size — 获得加密算法的分组大小
警告
本函数已自 PHP 7.1.0 起废弃。强烈建议不要使用本函数。
说明
mcrypt_get_block_size(int
$cipher
): intmcrypt_get_block_size(string
$cipher
, string $mode
): int第一个原型针对 libmcrypt 2.2.x, 第二个原型针对 libmcrypt 2.4.x 或 2.5.x。
mcrypt_get_block_size() 用来获取
cipher
(其中包括了加密模式)
加密算法分组大小。
mcrypt_enc_get_block_size() 函数更加有用, 因为它可以使用 mcrypt_module_open() 函数所返回的资源。
参数
-
cipher
-
MCRYPT_ciphername
常量中的一个,或者是字符串值的算法名称。 -
mode
-
MCRYPT_MODE_modename
常量中的一个,或以下字符串中的一个:"ecb","cbc","cfb","ofb","nofb" 和 "stream"。
返回值
返回以字节为单位的此算法的分组数据大小。 或者在失败时返回 false
。
范例
示例 #1 mcrypt_get_block_size() 例程
在 libmcrypt 2.4.x 和 2.5.x 下 如何使用本函数。
<?php
echo mcrypt_get_block_size('tripledes', 'ecb'); // 8
?>
参见
- mcrypt_get_key_size() - 获取指定加密算法的密钥大小
- mcrypt_enc_get_block_size() - 返回打开的算法的分组大小
- mcrypt_encrypt() - 使用给定参数加密明文

User Contributed Notes 1 note
mehaase at gmail dot com ¶
7 years ago
You should explain that the block size is return in BYTES, not the more commonly used unit, bits. Many readers are not going to know the DES block size and figure this out on their own.
备份地址:http://www.lvesu.com/blog/php/function.mcrypt-get-block-size.php