innmind/hash
最新稳定版本:1.7.0
Composer 安装命令:
composer require innmind/hash
包简介
Files incremental hash
README 文档
README
This component allows to incrementally compute the hash of a file (or any sequence of strings).
Installation
composer require innmind/hash
Usage
use Innmind\OperatingSystem\Factory; use Innmind\Url\Path; use Innmind\Hash\{ Hash, Value, }; use Innmind\Immutable\Set; $hashes = Factory::build() ->filesystem() ->mount(Path::of('some-folder/')) ->all() ->map(Hash::sha512->ofFile(...)); $hashes; // Set<Value>
Since the computation doesn't rely on the filesystem it can be called on content that is not on the filesystem and that cannot be fitted in memory.
Examples:
use Innmind\OperatingSystem\Factory; use Innmind\Http\{ Message\Request\Request, Message\Method, ProtocolVersion, }; use Innmind\Url\Url; use Innmind\Server\Control\Server\Command; use Innmind\Hash\{ Hash, Value, }; $os = Factory::build(); $os ->remote() ->http()(new Request( Url::of('https://github.com'), Method::get, ProtocolVersion::v20, )) ->map(static fn($success) => $success->response()->content()) ->map(Hash::sha512->ofContent(...)) ->match( static fn($value) => $value, // Value static fn() => null, // http call failed ); $output = $os ->control() ->processes() ->execute( Command::foreground('git') ->withOption('version'), ) ->output() ->chunks() ->map(static fn($chunk) => $chunk[0]); // to only keep the chunk data Hash::sha512->ofSequence($output); // Value
统计信息
- 总下载量: 11.88k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-24