Open In App

PHP | hash_final() Function

The hash_final() function is an inbuilt function in PHP which is used to finalize an incremental hash and return the resulting digest. 

Syntax:



hash_final( $context, $raw_output )

Parameters: This function accept two parameters as mention above and describe below.

Return Value: This function returns a string containing the calculated message digest as lowercase hexits. 



Below programs illustrate the hash_final() function in PHP: 

Program 1: 




<?php
 
// PHP program to illustrate
// hash_final function
$gfg = hash_init('md5');
 
hash_update($gfg, 'GeeksforGeeks A CS Portal');
 
// Print result return by
// hash_final function
print(hash_final($gfg));
?>

Output:
a26b1748ffd7e4c9923336a3c8e9a4c3

Program 2: 




<?php
 
// PHP program to illustrate
// hash_final function
$gfg = hash_init('md5');
 
hash_update($gfg, 'GeeksforGeeks A CS Portal');
 
// Print result return by
// hash_final function
print(hash_final($gfg, false));
?>

Output:
a26b1748ffd7e4c9923336a3c8e9a4c3

Reference: http://php.net/manual/en/function.hash-final.php#refsect1-function.hash-final-parameters

Article Tags :