Skip to main content

Library to partialy hash files.

Project description

BuildLink CoverageLink LicenseLink IssuesLink

Library to partialy hash files.

Installation

pip install partialhash

Usage

import binascii
import partialhash


path = "examples/random.data"


# sha256 hash of full file
digest = partialhash.compute(path)
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))


# recursivly compute sha256 hash until scatter reaches zero
# uses digest to deterministically get next offset and seed value
digest = partialhash.compute(path, length=1024, scatter=4)
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.0.1.tar.gz (4.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page