Library to partialy hash files.
Project description
Library to partialy hash files.
Installation
pip install partialhash
Usage
# from examples/usage.py
import binascii
import partialhash
path = "examples/random.data"
# sha256 hash of full file
digest = partialhash.compute(path) # file path or file like object
print(binascii.hexlify(digest))
# sha256 hash of first 1024 bytes
digest = partialhash.compute(path, length=1024)
print(binascii.hexlify(digest))
# sha256 hash, skipping the first 512 bytes
digest = partialhash.compute(path, offset=512)
print(binascii.hexlify(digest))
# sha256 hash of seed + file data
digest = partialhash.compute(path, seed=b'seeddata')
print(binascii.hexlify(digest))
# sha256 hash of 256 byte sample with given seed
# which data is sampled depends on given seed
digest = partialhash.sample(path, 256, seed=b'seeddata')
print(binascii.hexlify(digest))
# sha256 hash of three 256 byte samples with given seed
# sample data will not overlap until sample size exceeds file size
digest = partialhash.sample(path, 256, sample_count=3, seed=b'seeddata')
print(binascii.hexlify(digest))
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
partialhash-1.1.3.tar.gz
(4.5 kB
view details)
File details
Details for the file partialhash-1.1.3.tar.gz
.
File metadata
- Download URL: partialhash-1.1.3.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 450c5ab46fc29f8800408857a03a554713103581d384796f6a79528417971cfb |
|
MD5 | fc392c11d84ff28c80c73732789618a6 |
|
BLAKE2b-256 | b96a993000528a32fabee9d2d9076e6c74c5940775bbcdc55093f45f27a56f8a |