Skip to main content

Fast coarse hashes from files

Project description

# Install

$ pip3 install litehash

Use

Fibonacci

Calculate the checksum based on the bytes located at an increasing distance from each other, and the file size. We will read more bytes from the file header than from the body.

from pathlib import Path
from litehash import file_to_hash_fibonacci

print(file_to_hash_fibonacci(Path('/path/to/file.dat')))

Equidistant

Calculate the checksum based on ten equidistant bytes, and the file size. The very first and the very last byte of the file will be among the ten read.

from pathlib import Path
from litehash import file_to_hash_equidistant 

print(file_to_hash_equidistant(Path('/path/to/file.dat'), n=10))

HashAlgo

The optional HashAlgo argument allows you to select a hashing algorithm.

By default, MD5 is used as a compromise between speed and size.

Algorithm Digest Size (bytes)
HashAlgo.crc32 4
HashAlgo.md5 24
HashAlgo.sha256 32
from pathlib import Path
from litehash import file_to_hash_fibonacci, HashAlgo

print(file_to_hash_fibonacci(Path('/path/to/file.dat'), algo=HashAlgo.crc32))

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

litehash-0.2.2.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

litehash-0.2.2-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

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