當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。