= 5.1.2, PHP 7, PHP 8, PECL hash >= 1.1)hash_update_stream — 從打開的流向活躍的哈希運(yùn)算上下文中填充數(shù)據(jù)說(shuō)明hash_update_stream(HashContext $context,">

hash_update_stream

(PHP 5 >= 5.1.2, PHP 7, PHP 8, PECL hash >= 1.1)

hash_update_stream從打開的流向活躍的哈希運(yùn)算上下文中填充數(shù)據(jù)

說(shuō)明

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

參數(shù)

context

hash_init() 函數(shù)返回的哈希運(yùn)算上下文。

handle

創(chuàng)建流的函數(shù)返回的打開的文件句柄。

length

要從 handle 向活躍的哈希運(yùn)算上下文中拷貝 的最大字符數(shù)。

返回值

handle 向哈希運(yùn)算上下文中實(shí)際填充的字節(jié)數(shù)量。

更新日志

版本 說(shuō)明
7.2.0 接收參數(shù)從資源類型修改為 HashContext 對(duì)象類型。

范例

示例 #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

參見

  • hash_init() - 初始化增量哈希運(yùn)算上下文
  • hash_update() - 向活躍的哈希運(yùn)算上下文中填充數(shù)據(jù)
  • hash_final() - 結(jié)束增量哈希,并且返回摘要結(jié)果
  • hash() - 生成哈希值 (消息摘要)
  • hash_file() - 給指定文件的內(nèi)容生成哈希值