philiprehberger-hash-utils
Simplified hashing helpers for strings, files, and checksums.
Installation
pip install philiprehberger-hash-utils
Usage
Hash Strings and Bytes
from philiprehberger_hash_utils import hash_string, hash_bytes
hash_string("hello world") # SHA-256 hex digest
hash_string("hello world", "md5") # MD5 hex digest
hash_bytes(b"\x00\x01\x02", "sha512") # SHA-512 hex digest
Hash Files
from philiprehberger_hash_utils import hash_file
digest = hash_file("large_file.bin") # Streams in chunks
digest = hash_file("data.csv", algorithm="blake2b")
Hash Dictionaries
from philiprehberger_hash_utils import hash_dict
# Deterministic — key order doesn't matter
hash_dict({"b": 2, "a": 1}) == hash_dict({"a": 1, "b": 2}) # True
Verify Checksums
from philiprehberger_hash_utils import verify_checksum
# Timing-safe comparison
is_valid = verify_checksum("download.zip", expected_sha256)
Supported Algorithms
md5, sha1, sha256 (default), sha512, blake2b
API
| Function / Class | Description |
|---|---|
hash_string(s, algorithm="sha256") |
Hash a string |
hash_bytes(data, algorithm="sha256") |
Hash raw bytes |
hash_file(path, algorithm="sha256", chunk_size=8192) |
Hash a file (streaming) |
hash_dict(d, algorithm="sha256") |
Deterministic dict hash |
verify_checksum(path, expected, algorithm="sha256") |
Timing-safe file verification |
SUPPORTED_ALGORITHMS |
List of supported algorithm names |
Development
pip install -e .
python -m pytest tests/ -v
Support
If you find this project useful:
License
Release files for philiprehberger-hash-utils 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| philiprehberger_hash_utils-0.1.9.tar.gz | 5.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| philiprehberger_hash_utils-0.1.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.2 kB
Release files / philiprehberger_hash_utils-0.1.9.tar.gz
| Download URL | philiprehberger_hash_utils-0.1.9.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed1cc8824a8200f74a972830193cb20b162b387f5cc84370dac970584cfcffbd
|
|
BLAKE2b-256 checksum How to use checksums |
4e72e9b769af80fd32fd0e12271b575656afc2a7be4a85950087c0672ab4e954
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / philiprehberger_hash_utils-0.1.9-py3-none-any.whl
| Download URL | philiprehberger_hash_utils-0.1.9-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c37e8f5661c8b8f3efddabcc1424331bdda8fc154528b4711f25f4df5698cc5
|
|
BLAKE2b-256 checksum How to use checksums |
2e118880db2c7650ac9944e6a8a0013874e12990908deba1d4ecd8a5e6ae7ae1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|