Open In App

PHP mhash_count() Function

Improve
Improve
Like Article
Like
Save
Share
Report

The mhash_count() function is an inbuilt function in PHP which is used to Gets the highest available hash ID  within the current MHash installed in system like SHA1, MD% etc. It takes zero input parameter and returns an integer value.

Syntax:

int mhash_count( void )

Parameter: This function does not accept any parameter.

Return Value: This function returns a numerically indexed array which contains the list of supported hashing algorithms.

Below program illustrates the mhash_count() function in PHP:

Program:

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);
          
}
?>


Output:

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

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


Last Updated : 31 Aug, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads