Hello folks! welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we are going to be studying about the PHP hash_final() Function.
The built-in hash_final() function is used to return the final message digest.
A message digest is a hash with lowercase hexits generated using hash algorithms. It is predominantly used in securing the data so that the message or data that is sent is not changed.
The built-in hash_final() function is used to return the final message digest.
A message digest is a hash with lowercase hexits generated using hash algorithms. It is predominantly used in securing the data so that the message or data that is sent is not changed.
Syntax
Following below is the syntax to use this function -
hash_final ( HashContext $context [, bool $raw_output = FALSE ] ) : string
Parameter Details
Sr.No | Parameter & Description |
---|---|
1 | HashContext context The hash context that you get using hash_init(). |
2 | raw_output It takes true or false as value. If true it will give you lowercase hexits otherwise raw binary data. By default the value is true. |
Return Value
It returns a string with calculated message digest of lowercase hexit. If the raw_output is set as FALSE, then the output is going be a string with raw binary data.
PHP Version
This PHP function works from PHP version greater than 5.1.2.
Example1
The following example illustrates the usage of the PHP hash_final() function -
<?php $hash_context = hash_init('md5'); hash_update($hash_context, 'Testing php'); hash_update($hash_context, ' hash functions.'); echo hash_final($hash_context); ?>
Output
When the above code is executed, it will produce the following result -
e4310012c89a4b8479fd83694a2a3a31
Example2
The following example illustrates the usage of the built-in hash_final() function with the raw_output set as TRUE -
<?php $hash_context = hash_init('md5'); hash_update($hash_context, 'Testing php'); echo hash_final($hash_context, true); ?>
Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we are going to be discussing about the PHP hash_hkdf() Function.
Do feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Do follow us on our various social media handles available and also subscribe to our newsletter to get our tutorial posts delivered directly to your emails.
Thanks for reading and bye for now.
Do feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Do follow us on our various social media handles available and also subscribe to our newsletter to get our tutorial posts delivered directly to your emails.
Thanks for reading and bye for now.