Skip to content
Library to partialy hash files.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
partialhash
tests
.gitignore
.travis.yml
LICENSE
Makefile
README.rst
setup.py

README.rst

partialhash

BuildLink CoverageLink LicenseLink IssuesLink

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))
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.