• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • mcrypt_get_block_size()

    (PHP 4, PHP 5, PHP 7 < 7.2.0, PECL mcrypt >= 1.0.0)

    获得加密算法的分组大小

    Warning

    This function has beenDEPRECATEDas of PHP 7.1.0. Relying on this functionis highly discouraged.

    说明

    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

    范例

    mcrypt_get_block_size()例程

    在 libmcrypt 2.4.x 和 2.5.x 下如何使用本函数。

    <?php
    echo mcrypt_get_block_size('tripledes', 'ecb'); // 8
    ?>
    

    参见

    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.