Skip to main content

Deterministic canonical JSON and stable UUID/hash generation

Project description

Biplex Utils Hash

Deterministic canonical JSON serialization for stable UUIDv5 and hashes.

Installation

pip install biplex_utils_hash

Usage

from biplex_utils_hash import canonical_json, uuid5_from_data, sha256_from_data

# Generate stable UUID from data (float precision issues are handled automatically)
uuid = uuid5_from_data({"price": 0.1 + 0.2})

# Generate stable SHA256 hash
hash_hex = sha256_from_data({"price": 0.1 + 0.2})

# Get canonical JSON representation
json_str = canonical_json({"price": 0.1 + 0.2})
# Returns: '{"price":"0.300000"}'

# Custom decimal precision
uuid = uuid5_from_data({"price": 0.123456789}, decimal_places=3)

Features

  • Deterministic output: Same data always produces the same hash/UUID
  • Float stability: Handles floating-point precision issues (0.1 + 0.2 problem)
  • Canonical JSON: Sorted keys, compact format, consistent decimal formatting
  • Support for common types: dict, list, tuple, set, datetime, date, UUID

API

canonical_json(data, *, decimal_places=None) -> str

Converts data to deterministic canonical JSON string.

uuid5_from_data(data, *, namespace=NAMESPACE_OID, decimal_places=None) -> UUID

Generates stable UUID5 from data.

sha256_from_data(data, *, decimal_places=None) -> str

Generates SHA256 hash from data.

normalize(data, *, decimal_places=6) -> Any

Normalizes data for deterministic serialization.

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

biplex_utils_hash-0.1.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

biplex_utils_hash-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file biplex_utils_hash-0.1.0.tar.gz.

File metadata

  • Download URL: biplex_utils_hash-0.1.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for biplex_utils_hash-0.1.0.tar.gz
Algorithm Hash digest
SHA256 64606bf25e91f8731d754a93896c487f4d0d2ca244998512861f559182a36263
MD5 cd7f8d247bfdc963f41f477de2def081
BLAKE2b-256 93359cc947b4bdd3d395d02822df5698695294b1078c5c1c28f9a434c0034b36

See more details on using hashes here.

File details

Details for the file biplex_utils_hash-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for biplex_utils_hash-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93f78378b4ed596f37430112ae1bc4c3a2158c2d57dddaf1f4ecaf5e637e34ce
MD5 55f2f9f7d6ad9087fbe7fa9e5acb85d2
BLAKE2b-256 3bfb6beda3a369cecdff32a539c3abb67f2954529224cd8885fa0e35674355eb

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