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
特此授予任何人免费获得此软件及其相关文档副本(“软件”)的副本的权利,不受任何限制地处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件的副本,并允许向提供软件的人提供软件以这样做,前提是以下条件
上述版权声明和本许可声明应包含在软件的所有副本或实质性部分中。
软件按“原样”提供,不提供任何形式的保证,无论是明示的还是暗示的,包括但不限于适销性、特定用途适用性和非侵权性保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论该责任源于合同、侵权或其他方式,源于、源于或与软件或软件的使用或其他交易有关。