Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

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

<?

$context = hash_init('sha384');

hash_update($context, 'Hello');

$return = hash_final($context);

echo $return;

?>
3519fe5ad2c596efe3e276a6f351b8fc0b03db861782490d45f7598ebd0ab5fd5520ed102f38c4a5ec834e98668035fc

2 · binary

<?

$context = hash_init('sha384');
$binary = true;

hash_update($context, 'Hello');

$return = hash_final($context, $binary);

echo $return . PHP_EOL . bin2hex($return);

?>
5�Z�Ŗ���v��Q��ۆ�I
E�Y��
��U �/8ĥ�N�f�5�
3519fe5ad2c596efe3e276a6f351b8fc0b03db861782490d45f7598ebd0ab5fd5520ed102f38c4a5ec834e98668035fc
HomeMenu