CakeFest 2024: The Official CakePHP Conference

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 起废弃并将自 PHP 7.2.0 起移除。强烈建议不要使用本函数。

说明

mcrypt_get_block_size(int $cipher): int|false
mcrypt_get_block_size(string $cipher, string $mode): int|false

第一个原型针对 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

?>

参见

add a note

User Contributed Notes 1 note

up
-5
mehaase at gmail dot com
9 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.
To Top