Open In App

PHP mhash_get_block_size() Function

Last Updated : 19 Aug, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

The mhash_get_block_size() function is an inbuilt function in PHP which is used to gets the block size of the specified hash. Gets the highest available hash ID within the current MHash installed in the system like SHA1, MD%, etc.

Syntax:

int mhash_get_block_size( int $hash )

Parameter: This function accepts one parameter as shown in the above syntax. The parameters are described below:

  • $Hash: The hash ID. One of the MHASH_hashname constants.

Return Value: This function returns the hash name and it’s block size which contains the list of supported hashing algorithms.

Example: Below program illustrates the mhash_get_block_size() function in PHP.

PHP




<?php
  
$maxHashCount = mhash_count();
  
for ($hashNumber = 0; $hashNumber <= 
        $maxHashCount; $hashNumber++) {
              
    // i-th hash name
    $hashName = mhash_get_hash_name($hashNumber);
      
    // i-th block size
    $hashSize = mhash_get_block_size($hashNumber);
      
    // Details of i-th hash
    print_r($hashName . " 's block size is" 
                . $hashSize . "\n");
}
?>


Output:

CRC32 's block size is4
MD5 's block size is16
SHA1 's block size is20
HAVAL256 's block size is32
's block size is
RIPEMD160 's block size is20
's block size is
TIGER 's block size is24
GOST 's block size is32
CRC32B 's block size is4
HAVAL224 's block size is28
HAVAL192 's block size is24
HAVAL160 's block size is20
HAVAL128 's block size is16
TIGER128 's block size is16
TIGER160 's block size is20
MD4 's block size is16
SHA256 's block size is32
ADLER32 's block size is4
SHA224 's block size is28
SHA512 's block size is64
SHA384 's block size is48
WHIRLPOOL 's block size is64
RIPEMD128 's block size is16
RIPEMD256 's block size is32
RIPEMD320 's block size is40
's block size is
SNEFRU256 's block size is32
MD2 's block size is16
FNV132 's block size is4
FNV1A32 's block size is4
FNV164 's block size is8
FNV1A64 's block size is8
JOAAT 's block size is4
lovely@lovely:~/Documents/php$

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads