Skip to main content

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 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

License

MIT

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

philiprehberger_hash_utils-0.1.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_hash_utils-0.1.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_hash_utils-0.1.1.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_hash_utils-0.1.1.tar.gz
Algorithm Hash digest
SHA256 deecf337504e17251f384fb9ed0e184333b87eb2694c8f806c86282ae9e0ff02
MD5 9fb5d81eacfd1b69a97c107921ac0614
BLAKE2b-256 320e6d168569ddb85dd83cd4d24d468c578540c0c478b90943850d7ec942314d

See more details on using hashes here.

File details

Details for the file philiprehberger_hash_utils-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_hash_utils-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fb54a3c569dd3ba7dced2c706aef86de3d93d2065d5f10b24c1f9a9a10751c13
MD5 566eca0635cc1bfbfcf9ae014f2b1e04
BLAKE2b-256 946e0c7c367c9a91d90353b1c6433cd766368ff3a4112179626aaab2e5585029

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page