略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: mcrypt_get_block_size

2024-05-02

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): int
mcrypt_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

?>

参见

add a noteadd a note

User Contributed Notes 1 note

up
0
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.

官方地址:https://www.php.net/manual/en/function.mcrypt-get-block-size.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3