• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • hash_update_stream()

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

    从打开的流向活跃的哈希运算上下文中填充数据

    说明

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

    参数

    $context

    由hash_init()函数返回的哈希运算上下文。

    $handle

    创建流的函数返回的打开的文件句柄。

    $length

    要从$handle向活跃的哈希运算上下文中拷贝的最大字符数。

    返回值

    $handle向哈希运算上下文中实际填充的字节数量。

    更新日志

    版本说明
    7.2.0接收参数从资源类型修改为HashContext对象类型。

    范例

    Example #1hash_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);
    ?>
    

    以上例程会输出:

    5c6ffbdd40d9556b73a21e63c3e0e904
    

    参见

    上篇:hash_update_file()

    下篇:hash_update()