hash_update_stream

アクティブなハッシュコンテキストに、オープンしているストリームから データを投入する

説明

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

パラメータ

context

hash_init が返すハッシュコンテキスト。

stream

ストリーム作成用の関数が返す、オープンしているファイルハンドル。

length

stream からハッシュコンテキストにコピーする 最大文字数。

戻り値

stream からハッシュコンテキストに追加された 実際のバイト数を返します。

変更履歴

バージョン 説明
7.2.0 リソースの代わりに 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
  • hash_final
  • hash
  • hash_file