Simplified hashing helpers for strings, files, and checksums
Project description
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
hash_string(s, algorithm="sha256")— Hash a stringhash_bytes(data, algorithm="sha256")— Hash raw byteshash_file(path, algorithm="sha256", chunk_size=8192)— Hash a file (streaming)hash_dict(d, algorithm="sha256")— Deterministic dict hashverify_checksum(path, expected, algorithm="sha256")— Timing-safe file verification
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file philiprehberger_hash_utils-0.1.3.tar.gz.
File metadata
- Download URL: philiprehberger_hash_utils-0.1.3.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d242df4a0960f53566e354e9f8d69f1e8aca5734bc0155bbd9bc88d4f50e046
|
|
| MD5 |
3d3a6d3c57d93bc46f98e71cd649f6d1
|
|
| BLAKE2b-256 |
89c465da2f3cdd9a9ad25da2974c5f3702e2ddfd27545def69007ea01b0c9738
|
File details
Details for the file philiprehberger_hash_utils-0.1.3-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_hash_utils-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
532be4095830e5d91abe778a7d210acecabfa66a21817d109c65dba925048871
|
|
| MD5 |
39cc02a97307d8639af3582aa91c683c
|
|
| BLAKE2b-256 |
ec81d8bed84742e9ac606801e546d9442005e9012a1af3ceb2daecc778b7c162
|