bantu / stream-filter-hash
Stream filter piping data through a hash function.
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 0
Forks: 1
Open Issues: 0
pkg:composer/bantu/stream-filter-hash
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2025-10-21 08:06:42 UTC
README
Installation
Through composer:
$ composer require bantu/stream-filter-hash
Usage
Use HashFilter::appendToWriteStream($stream, $params) to calculate a checksum
of everything written to $stream. The $params argument has to be an array
specifying the hash algorithm to use via the algo array key (e.g. md5 or
sha256). Furthermore $params either needs to be passed a callback via the
callback array key or an output stream using the stream array key.
Example using Stream
Create an output.txt.sha256 file containing a checksum of everything you
write to output.txt.
require 'vendor/autoload.php'; $dest = fopen('output.txt', 'w+b'); $hash = fopen('output.txt.md5', 'w+b'); \bantu\StreamFilter\Hash\HashFilter::appendToWriteStream($dest, array( 'algo' => 'sha256', 'stream' => $hash, )); fwrite($dest, 'The quick brown fox jumps over the lazy dog'); fclose($dest); fclose($hash);