wyrihaximus / react-stream-hash
用于 ReactPHP 流的即时哈希计算器
1.1.0
2019-01-01 17:37 UTC
Requires
- php: ^7.2
- react/stream: ^1.1.0
Requires (Dev)
- api-clients/cs-fixer-config: ^1.1
- api-clients/test-utilities: ^5.4
- react/promise-stream: ^1.0 || ^0.1.1
This package is auto-updated.
Last update: 2024-09-05 04:10:03 UTC
README
安装
要通过 Composer 安装,请使用以下命令,它将自动检测最新版本并将其绑定到 ^
。
composer require wyrihaximus/react-stream-hash
使用方法
可写流
$algo = 'sha512'; // Change to any desired algo from hash_algos() $streamToHash = new ThroughStream(); // Constructor accepts a third $key argument in case you want a HMAC hash $stream = new WritableStreamHash($streamToHash, $algo); $stream->on('hash', function ($hash, $algo) { // Do with what you need the hash for }); $stream->on('hash_raw', function ($hash, $algo) { // Do with what you need the raw hash for }); // Write to the stream $stream->write('foo'); $stream->end('bar');
可读流
$algo = 'sha512'; // Change to any desired algo from hash_algos() $streamToHash = new ThroughStream(); // Constructor accepts a third $key argument in case you want a HMAC hash $stream = new ReadableStreamHash($streamToHash, $algo); $stream->on('hash', function ($hash, $algo) { // Do with what you need the hash for }); $stream->on('hash_raw', function ($hash, $algo) { // Do with what you need the raw hash for }); // The readable emits data when written to $streamToHash->write('foo'); $streamToHash->end('bar');
贡献
有关详细信息,请参阅CONTRIBUTING。
许可协议
版权所有 2017 Cees-Jan Kiewiet
特此授予任何获得此软件及其相关文档副本(以下简称“软件”)的人权,在不受限制的情况下处理软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本的权利,并允许软件提供者这样做,前提是遵守以下条件
上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。
软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、针对特定目的的适用性和非侵权性。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论此类责任是基于合同、侵权或其他方式,是否因软件或软件的使用或其他交易而产生。