Python的fs-verity摘要实现
项目描述
fsverity-hash
Python对fs-verity哈希方案的实现。
安装
python -mpip install fsverity-hash
用法
FSVerityHash
提供了一个类似于hashlib的接口
>>> import fsverity_hash
>>> m = fsverity_hash.FSVerityHash()
>>> m.update(b"Nobody inspects the spammish repetition")
>>> m.digest()
b'>\xd6s\xd52<\x9e\x1c`\x82\x0f td\xb0\xb8X\xa9\x0b\xa4\xff\x94\x0b\x12=\xd1kBV\x99\xce\xbe'
>>> m.hexdigest()
'3ed673d5323c9e1c60820f207464b0b858a90ba4ff940b123dd16b425699cebe'
的fsverity digest
命令产生相同的摘要
$ echo -n "Nobody inspects the spammish repetition" > file.txt
$ fsverity digest file.txt
sha256:3ed673d5323c9e1c60820f207464b0b858a90ba4ff940b123dd16b425699cebe file.txt
该模块公开了与fsverity digest
相同的命令行接口
$ echo -n "Nobody inspects the spammish repetition" > spam.txt
$ fsverity digest spam.txt
sha256:3ed673d5323c9e1c60820f207464b0b858a90ba4ff940b123dd16b425699cebe spam.txt
$ python3 -m fsverity_hash spam.txt
sha256:3ed673d5323c9e1c60820f207464b0b858a90ba4ff940b123dd16b425699cebe spam.txt
$ python3 -m fsverity_hash --help
usage: fsverity_hash.py [-h] [--hash-alg {sha256,sha512}] [--block-size BYTES]
[--compact]
[FILE ...]
Compute fs-verity hashes
positional arguments:
FILE Input file(s) to process (default: stdin)
optional arguments:
-h, --help show this help message and exit
--hash-alg {sha256,sha512}
Merkle tree block hashing algorithm (default: sha256)
--block-size BYTES Merkle tree block size in bytes (default: 4096)
--compact Omit the hash algorithm name when printing digests
限制
- 最多可以哈希8 GiB。这是一个实现限制,而不是fs-verity哈希的一般限制。
- 未实现加盐哈希。
- 没有自动测试。
- 未测试自定义块大小。
FSVerityHash
对象不能被复制。
其他实现
- https://git.kernel.org/pub/scm/fs/fsverity/fsverity-utils.git引用libfsverity实现和
fsverity
命令 - https://github.com/rvolgers/fs-verity-rs Rust包
进一步阅读
项目详情
关闭
fsverity-hash-0.0.5.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | a0bb679a010bd6df69fa705d97e3cb94feb2e30608237039e403298da230ae9f |
|
MD5 | 492e0dfef06ed0e83f0182d16070eef1 |
|
BLAKE2b-256 | 435726abf385272754a253822f8a5dd9692ce88e2e33e8d505164685101aa4a0 |
关闭
fsverity_hash-0.0.5-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 6f56eba3db850b15fefaea7885f7c4fbbf1c27f1cc70e3e1ae00dc21015a5bc1 |
|
MD5 | 1b9be384fafe23b9ee77ca507061759d |
|
BLAKE2b-256 | 3b09962e59cbd67dd566c82e2dcfadea212f1055a496e6da932e6cbe0f87fa91 |