(PHP 5 >= 5.1.2, PHP 7, PHP 8, PECL hash >= 1.1)
hash_update_stream — 從打開(kāi)的流向活躍的哈希運算上下文中填充數據
$context, resource $handle, int $length = -1): int
context由 hash_init() 函數返回的哈希運算上下文。
handle創(chuàng )建流的函數返回的打開(kāi)的文件句柄。
length
要從 handle 向活躍的哈希運算上下文中拷貝
的最大字符數。
從 handle 向哈希運算上下文中實(shí)際填充的字節數量。
| 版本 | 說(shuō)明 |
|---|---|
| 7.2.0 | 接收參數從資源類(lèi)型修改為 HashContext 對象類(lèi)型。 |
示例 #1 hash_update_stream() 例程
<?php
$fp = tmpfile();
fwrite($fp, 'The quick brown fox jumped over the lazy dog.');
rewind($fp);
$ctx = hash_init('md5');
hash_update_stream($ctx, $fp);
echo hash_final($ctx);
?>
以上例程會(huì )輸出:
5c6ffbdd40d9556b73a21e63c3e0e904