Monday, November 17, 2025
HomeLanguagesPHP | hash_final() Function

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.

  • $context: This parameter is used to specify the hashing context returned by hash_init() function
  • $raw_output: This parameter is used to set Boolean value. If this parameter set to True then output contains raw binary data and if parameter set to False then output contains lowercase hexits.

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
 
// PHP program to illustrate
// hash_final function
$gfg = hash_init('md5');
 
hash_update($gfg, 'neveropen A CS Portal');
 
// Print result return by
// hash_final function
print(hash_final($gfg));
?>


Output:

a26b1748ffd7e4c9923336a3c8e9a4c3

Program 2: 

php




<?php
 
// PHP program to illustrate
// hash_final function
$gfg = hash_init('md5');
 
hash_update($gfg, 'neveropen 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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32402 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6772 POSTS0 COMMENTS
Nicole Veronica
11921 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11992 POSTS0 COMMENTS
Shaida Kate Naidoo
6899 POSTS0 COMMENTS
Ted Musemwa
7155 POSTS0 COMMENTS
Thapelo Manthata
6852 POSTS0 COMMENTS
Umr Jansen
6843 POSTS0 COMMENTS