Simplified hashing helpers for strings, files, and checksums
pip install philiprehberger-hash-utilsSimplified hashing helpers for strings, files, and checksums.
pip install philiprehberger-hash-utils
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
from philiprehberger_hash_utils import hash_file
digest = hash_file("large_file.bin") # Streams in chunks
digest = hash_file("data.csv", algorithm="blake2b")
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
from philiprehberger_hash_utils import verify_checksum
# Timing-safe comparison
is_valid = verify_checksum("download.zip", expected_sha256)
md5, sha1, sha256 (default), sha512, blake2b
| 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 |
pip install -e .
python -m pytest tests/ -v
If you find this project useful: