hash_update_stream
(PHP 5 >= 5.1.2, PHP 7, PHP 8, PECL hash >= 1.1)
hash_update_stream — 从打开的流向活跃的散列运算上下文中填充数据
说明
参数
context
-
由 hash_init() 函数返回的散列运算上下文。
stream
-
创建流的函数返回的打开的文件句柄。
length
-
要从
stream
向活跃的散列运算上下文中拷贝的最大字符数。
返回值
从 stream
向散列运算上下文中实际填充的字节数量。
示例
示例 #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() - 向活跃的哈希运算上下文中填充数据
- hash_update_stream()
- hash_final() - 结束增量散列且返回摘要结果
+添加备注
用户贡献的备注 1 note
qiuty at mail dot ru ¶
3 years ago
This can be obvious, but hash_update_stream() move file pointer. So, use rewind(), if you plan to read the file after hashing.
备份地址:http://www.lvesu.com/blog/php/function.hash-update-stream.php