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

hash_update_stream

Description

The hash_update_stream of Hash for PHP pump data into an active hashing context from an open stream.

Syntax

hash_update_stream(HashContext $context, resource $stream, int $length = -1): int

Parameters

context

Hashing context returned by hash_init().

stream

Open file handle as returned by any stream creation function.

length

Maximum number of characters to copy from stream into the hashing context.

Return

Actual number of bytes added to the hashing context from stream.

Examples

1 · context stream

<?

$context = hash_init('sha384');
$stream = tmpfile();
fwrite($stream, 'Hello');
rewind($stream);

hash_update_stream($context, $stream);

echo hash_final($context);

?>
3519fe5ad2c596efe3e276a6f351b8fc0b03db861782490d45f7598ebd0ab5fd5520ed102f38c4a5ec834e98668035fc

2 · length

<?

$context = hash_init('sha384');
$stream = tmpfile();
fwrite($stream, 'Hello');
rewind($stream);
$length = 2;

hash_update_stream($context, $stream, $length);

echo hash_final($context);

?>
ef79aa83fbc20dd717eef1e985c5b3c7f2fdbe8351665f2ac47b5c4b01950d67936f53eaf1e574ae6bf125a653481bb7

3 · Return

<?

$context = hash_init('sha384');
$stream = tmpfile();
fwrite($stream, 'Hello');
rewind($stream);

$return = hash_update_stream($context, $stream);

hash_final($context);

var_export($return);

?>
5
HomeMenu