hash_final
Description
The hash_final of Hash for PHP finalize an incremental hash and return resulting digest.
Syntax
hash_final( HashContext $context, bool $binary = false ): string
Parameters
context
Hashing context returned by hash_init().
binary
When set to true, outputs raw binary data. false outputs lowercase hexits.
Return
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.
Examples
1 · context
<? $algo = "sha384"; $context = hash_init($algo); $data = "mydata"; hash_update($context, $data); $return = hash_final($context); echo $return;
8a40b2c5c3861f6bd1c175adffcb109c84e6e0a7d53f1cb6d698bcc9bbfcbe5d9175fa446a606c8f6e7aaf592ad6ad4c
2 · binary
<? $algo = "sha384"; $context = hash_init($algo); $data = "mydata"; hash_update($context, $data); $binary = true; $return = hash_final($context, $binary); echo $return . PHP_EOL . bin2hex($return);
�@��Æk�u��������?�֘�ɻ��]�u�Dj`l�nz�Y*֭L 8a40b2c5c3861f6bd1c175adffcb109c84e6e0a7d53f1cb6d698bcc9bbfcbe5d9175fa446a606c8f6e7aaf592ad6ad4c