当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


PHP mhash_count()用法及代码示例


mhash_count()函数是PHP中的内置函数,用于获取安装在系统中的当前MHash(如SHA1,MD%等)中的最高可用哈希ID。它采用零输入参数并返回整数值。

用法:

int mhash_count( void )

参数:此函数不接受任何参数。

返回值:此函数返回一个数字索引的数组,其中包含受支持的哈希算法列表。

以下示例程序旨在说明PHP中的mhash_count()函数:



程序:

PHP

<?php 
  
$nr = mhash_count(); 
  
for ($hashNumber = 0; $hashNumber <= $nr; $hashNumber++) { 
  
    // i-th hash name 
    $hashName = mhash_get_hash_name($hashNumber); 
  
    // i-th hash block size 
    $hashSize = mhash_get_block_size($hashNumber); 
    
   // Details of i-th hash 
    echo sprintf("%d Hash is %s and its block size is %d\n",  
                 $hashNumber, $hashName, $hashSize); 
          
} 
?>

输出:

0 Hash is CRC32 and its block size is 4
1 Hash is MD5 and its block size is 16
2 Hash is SHA1 and its block size is 20
3 Hash is HAVAL256 and its block size is 32
4 Hash is  and its block size is 0
5 Hash is RIPEMD160 and its block size is 20
6 Hash is  and its block size is 0
7 Hash is TIGER and its block size is 24
8 Hash is GOST and its block size is 32
9 Hash is CRC32B and its block size is 4
10 Hash is HAVAL224 and its block size is 28
11 Hash is HAVAL192 and its block size is 24
12 Hash is HAVAL160 and its block size is 20
13 Hash is HAVAL128 and its block size is 16
14 Hash is TIGER128 and its block size is 16
15 Hash is TIGER160 and its block size is 20
16 Hash is MD4 and its block size is 16
17 Hash is SHA256 and its block size is 32
18 Hash is ADLER32 and its block size is 4
19 Hash is SHA224 and its block size is 28
20 Hash is SHA512 and its block size is 64
21 Hash is SHA384 and its block size is 48
22 Hash is WHIRLPOOL and its block size is 64
23 Hash is RIPEMD128 and its block size is 16
24 Hash is RIPEMD256 and its block size is 32
25 Hash is RIPEMD320 and its block size is 40
26 Hash is  and its block size is 0
27 Hash is SNEFRU256 and its block size is 32
28 Hash is MD2 and its block size is 16
29 Hash is FNV132 and its block size is 4
30 Hash is FNV1A32 and its block size is 4
31 Hash is FNV164 and its block size is 8
32 Hash is FNV1A64 and its block size is 8
33 Hash is JOAAT and its block size is 4

参考: https://www.php.net/manual/en/function.mhash-count.php

相关用法


注:本文由纯净天空筛选整理自shubham_singh大神的英文原创作品 PHP mhash_count() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。