Hash

If you need to obtain a hash of the stream's content, then use the hash() method.

The method accepts a number of arguments;

  • string $algo: Name of the hashing algorithm to be used.
  • bool $binary: (optional) If true, outputs raw binary data.
  • int $flags: (optional) Optional settings for hash generation
  • string $key: (optional) Shared secret key, when HASH_HMAC specified in $flags
  • array $options: (optional) Options for the specified hashing algorithm
$stream = FileStream::open('persons.txt', 'rb');

echo $stream->hash('crc32'); // d5aad468

For additional information, please review PHP documentation: