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

hash_update_file

Description

The hash_update_file of Hash for PHP pump data into an active hashing context from a file.

Syntax

hash_update_file(
    HashContext $context,
    string $filename,
    ?resource $stream_context = null
): bool

Parameters

context

Hashing context returned by hash_init().

filename

URL describing location of file to be hashed; Supports fopen wrappers.

stream_context

Stream context as returned by stream_context_create().

Return

Returns true on success or false on failure.

Examples

1 · context filename

<?

$context = hash_init('sha384');
$filename = $_SERVER['DOCUMENT_ROOT'] . '/assets/txt/1.txt';

hash_update_file($context, $filename);

echo hash_final($context);

?>
59e1748777448c69de6b800d7a33bbfb9ff1b463e44354c3553bcdb9c666fa90125a3c79f90397bdf5f6a13de828684f

2 · stream_context

<?

$context = hash_init('sha384');
$filename = $_SERVER['DOCUMENT_ROOT'] . '/assets/txt/1.txt';
$stream_context = stream_context_create(array('http' => array('method' => 'POST')));

hash_update_file($context, $filename, $stream_context);

echo hash_final($context);

?>
59e1748777448c69de6b800d7a33bbfb9ff1b463e44354c3553bcdb9c666fa90125a3c79f90397bdf5f6a13de828684f

3 · return

<?

$context = hash_init('sha384');
$filename = $_SERVER['DOCUMENT_ROOT'] . '/assets/txt/1.txt';
$stream_context = stream_context_create(array('http' => array('method' => 'POST')));

$return = hash_update_file($context, $filename, $stream_context);

hash_final($context);

var_export($return);

?>
true
HomeMenu