hash_final()
hash_final() — Finalize an incremental hash and return resulting digest.
Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.1.2, PHP 7, PHP 8, PECL hash >= 1.1. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
Signature
hash_final(HashContext $context, bool $binary = false): string
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $context | HashContext | Hashing context returned by hash_init(). |
| $binary | bool | When set to true, outputs raw binary data. false outputs lowercase hexits. |
Return value
Returns a string containing the calculated message digest as lowercase hexits unless binary is set to true in which case the raw binary representation of the message digest is returned.
Example
The PHP manual ships no example for hash_final(); the signature and the parameter table above are the contract.
Changelog
| Version | Change |
|---|---|
| 7.2.0 | Accept HashContext instead of resource. |
See also
hash_init(), hash_update(), hash_update_stream(), hash_update_file()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page hash_final() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.