hash_final() – Finalize Incremental Hash and Return Digest
The hash_final() function completes an incremental hash operation in PHP, returning either a raw binary digest or a lowercase hexadecimal string based on the raw_output flag, with usage illustrated through a complete example.
The hash_final() function ends an incremental hash operation and returns the resulting digest. Its signature is
string hash_final(resource $context[, bool $raw_output = false]).
Parameters
context : The hash context resource returned by hash_init().
raw_output : When set to TRUE, the function returns the raw binary digest; when FALSE, it returns a lowercase hexadecimal string.
Return value
If $raw_output is TRUE, a binary string is returned; otherwise a hexadecimal string is returned.
Example
<?php
$ctx = hash_init('sha1');
hash_update($ctx, 'The quick brown fox jumped over the lazy dog.');
echo hash_final($ctx);
?>Output
c0854fb9fb03c41cce3802cb0d220529e6eef94eSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
