PHP8 hash_update_stream

2024-03-01 09:28 更新

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

hash_update_stream — 從打開的流向活躍的散列運算上下文中填充數(shù)據(jù)

說明

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

參數(shù) 

context

由 hash_init() 函數(shù)返回的散列運算上下文。

stream

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

length

要從 stream 向活躍的散列運算上下文中拷貝的最大字符數(shù)。

返回值 

從 stream 向散列運算上下文中實際填充的字節(jié)數(shù)量。

更新日志 

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

示例 

示例 #1 hash_update_stream() 示例

<?php
$fp = tmpfile();
fwrite($fp, 'jumped over the lazy dog.');
rewind($fp);

$ctx = hash_init('sha256');
hash_update($ctx, 'The quick brown fox ');
hash_update_stream($ctx, $fp);
echo hash_final($ctx);
?>

以上示例會輸出:

68b1282b91de2c054c36629cb8dd447f12f096d3e3c587978dc2248444633483

參見 

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


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號