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
Release history Release notifications | RSS feed
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 details)
Built Distribution
File details
Details for the file litehash-0.2.2.tar.gz
.
File metadata
- Download URL: litehash-0.2.2.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2938cfb9bf1a54d3e27e8dc88ebdd928469dd03dd1275633e95cb0b585d56ca |
|
MD5 | c6a4434c4a5d8bf5c8a082bed0092115 |
|
BLAKE2b-256 | 5fb512db500c12ec11f7ffc3cc95bac0d3df0edff5fa140165c7aaf241aee614 |
File details
Details for the file litehash-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: litehash-0.2.2-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9bde6ac0f9c405cd3aa85ff3e25a9230fa03f32c81a2f533fea711d39403d7a |
|
MD5 | dbecf6ab6a0558838134cc7b1dc4e077 |
|
BLAKE2b-256 | 7abfb8bfc2a89384198b93790ec825318eef1b255ed79479b3907f90709ff4ba |