Skip to main content

No project description provided

Project description

uuid_blake3

CI PyPI version License: MIT

Fast, secure deterministic UUIDs using BLAKE3 hashing, with optional structured metadata support.

Features

  • Fast & Secure: Uses BLAKE3 instead of SHA-1 or MD5 for better performance and cryptographic security. Or simply because SHA1 isn't cool any more
  • Deterministic: Same inputs always produce the same UUID
  • RFC 4122 Compliant: Generated UUIDs follow the standard format
  • Metadata Support: Enhanced version supports structured metadata beyond simple namespace+name
  • Type Safe: Built in Rust with Python bindings for reliability and performance

Installation

pip install uuid_blake3

Quick Start

Basic Usage (like UUID v3/v5)

import uuid_blake3

# Generate deterministic UUIDs from namespace and name
uuid1 = uuid_blake3.uuid("my-namespace", "my-resource")
uuid2 = uuid_blake3.uuid("my-namespace", "my-resource")

assert uuid1 == uuid2  # Always the same for identical inputs
print(uuid1)  # e.g., b6839270-3331-531b-99b5-e67404c687cb

With Metadata

import uuid_blake3

# Enhanced version with key/value metadata
metadata = {
    "version": "1.0",
    "environment": "production",
    "user_id": 12345,
    "production": False,
}

uuid_meta = uuid_blake3.uuid_with_metadata(
    namespace="my-app",
    name="user-session",
    metadata=metadata
)

print(uuid_meta)  # Deterministic UUID incorporating all metadata

Why BLAKE3?

Traditional UUID v3 and v5 use MD5 and SHA-1 respectively, which have known cryptographic weaknesses. BLAKE3 offers:

  • Speed: Significantly faster than SHA-1/SHA-256
  • Security: Cryptographically secure with no known vulnerabilities
  • Simplicity: Clean, modern design
  • Versatility: Supports keyed hashing and extensible output

Metadata Handling

The uuid_with_metadata function provides deterministic UUID generation with complex structured data:

# All these produce the same UUID (order doesn't matter)
meta1 = {"key1": "value1", "key2": "value2"}
meta2 = {"key2": "value2", "key1": "value1"}

uuid1 = uuid_blake3.uuid_with_metadata("ns", "name", meta1)
uuid2 = uuid_blake3.uuid_with_metadata("ns", "name", meta2)
assert uuid1 == uuid2

# Supports various data types
metadata = {
    "string": "text",
    "number": 42,
    "float": 3.14,
    "boolean": True,
    "bytes": b"binary-data",
    "complex": {"nested": "objects"}  # Serialized via str()
}

Supported Types

  • Strings: UTF-8 encoded
  • Integers: Little-endian byte representation
  • Floats: IEEE 754 little-endian bytes
  • Booleans: Single byte (0x00/0x01)
  • Bytes: Direct binary data
  • Complex types: String representation via str()

API Reference

uuid(namespace: str, name: str) -> uuid.UUID

Generate a deterministic UUID from namespace and name (similar to UUID v3/v5).

Parameters:

  • namespace: Namespace string to scope the UUID
  • name: Name/identifier within the namespace

Returns: A uuid.UUID object

uuid_with_metadata(namespace: str, name: str, metadata: dict) -> uuid.UUID

Generate a deterministic UUID incorporating structured metadata.

Parameters:

  • namespace: Namespace string to scope the UUID
  • name: Name/identifier within the namespace
  • metadata: Dictionary of metadata to include in hash. Nested structures are serialized to strings, so you may want to serialize to JSON first or stick to simple types.

Returns: A uuid.UUID object

Raises: TypeError if metadata is not a dictionary

The first sixteen bits of the UUID are derived from only the namespace and the name while the remaining bits are derived from everything: namespace, name, and metadata. This means that sharing the same namespace and name will produce UUIDs that are relatively close to each other, which can be convenient if you organize data based on the UUID.

Security Considerations

This is NOT cryptographically secure. First, a standard UUID is 128 bits long with 122 actual data bits, which is clearly not enough for cryptographic purposes. Second, the library is designed to derive strings and metadata into reproducible IDs but is not designed to be a secure hashing function.

When to Use

  • Use uuid() for simple namespace+name scenarios (like traditional UUID v3/v5)
  • Use uuid_with_metadata() when you need to incorporate additional context that affects uniqueness
  • Consider JSON serialization for complex metadata to ensure consistent representation

Development

This project uses Rust with Python bindings via PyO3 and Maturin.

# Install Rust toolchain, if you haven't already done it
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Install Python dependencies
pip install maturin pytest

# Build and install in development mode
maturin develop

# Run tests
pytest

Licence

MIT Licence - see LICENSE file for details.

Contributing

Contributions welcome! Please open an issue or submit a pull request.

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

uuid_blake3-0.1.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distributions

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

uuid_blake3-0.1.0-cp38-abi3-win_amd64.whl (140.4 kB view details)

Uploaded CPython 3.8+Windows x86-64

uuid_blake3-0.1.0-cp38-abi3-win32.whl (156.7 kB view details)

Uploaded CPython 3.8+Windows x86

uuid_blake3-0.1.0-cp38-abi3-musllinux_1_2_x86_64.whl (447.6 kB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ x86-64

uuid_blake3-0.1.0-cp38-abi3-musllinux_1_2_i686.whl (508.8 kB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ i686

uuid_blake3-0.1.0-cp38-abi3-musllinux_1_2_armv7l.whl (533.4 kB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARMv7l

uuid_blake3-0.1.0-cp38-abi3-musllinux_1_2_aarch64.whl (446.2 kB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

uuid_blake3-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (276.6 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

uuid_blake3-0.1.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (291.9 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ s390x

uuid_blake3-0.1.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (401.2 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ppc64le

uuid_blake3-0.1.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (270.4 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARMv7l

uuid_blake3-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (267.9 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

uuid_blake3-0.1.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl (329.7 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.5+ i686

uuid_blake3-0.1.0-cp38-abi3-macosx_11_0_arm64.whl (239.3 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

uuid_blake3-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl (255.9 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: uuid_blake3-0.1.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.0

File hashes

Hashes for uuid_blake3-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6bd285e32a1d4e76dbbca43316b8188fd47c41e382ef8b3a54feed76f71d26f5
MD5 01b05d4626429372a78b3a369543b576
BLAKE2b-256 db8591ea059e93b44218dce650164b14edcc3896b18d516125364654f8fbff5a

See more details on using hashes here.

File details

Details for the file uuid_blake3-0.1.0-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for uuid_blake3-0.1.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8c2265227b0396c0cf7f996db6caff5ec3e7cf3d57aae67f22027a0b80177300
MD5 ca3b675618f187fd868a335c56d21e2e
BLAKE2b-256 5230c417b652d69fbdd4d87a93da9de14c981e86d497a1a927f80b9e3932f0f6

See more details on using hashes here.

File details

Details for the file uuid_blake3-0.1.0-cp38-abi3-win32.whl.

File metadata

  • Download URL: uuid_blake3-0.1.0-cp38-abi3-win32.whl
  • Upload date:
  • Size: 156.7 kB
  • Tags: CPython 3.8+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.0

File hashes

Hashes for uuid_blake3-0.1.0-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 a501c588840adebc52828cf7f377416422d2aa3cb1ea5d9377e923e94f99b666
MD5 1ba73393e036ffb10e0a3893c1190229
BLAKE2b-256 2b5550abe9bd2cc313af9b9dcf24c0b366bd08bc1d73075abadcb938c213d299

See more details on using hashes here.

File details

Details for the file uuid_blake3-0.1.0-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for uuid_blake3-0.1.0-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e3d00c259d3d907c50524a0b5cbaa91a27256b5b86b440ff6c41a0caf60ebe5a
MD5 c5c513ccd57ac37479964f7f83efd32c
BLAKE2b-256 16a0a3b18656bae2719b5edbb2d4644e2ead4093725c2227be8ef553b219ecaa

See more details on using hashes here.

File details

Details for the file uuid_blake3-0.1.0-cp38-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for uuid_blake3-0.1.0-cp38-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 90985827a6363feb7e520dd8ed3440d527ed7bcc34a4e9a1ced831c3616dbdb3
MD5 253ba637b0b2322e606bec8da53fe49a
BLAKE2b-256 f4d4124173d1544137a21edf8993df59937971e4d5b387e40eb53df87162b27d

See more details on using hashes here.

File details

Details for the file uuid_blake3-0.1.0-cp38-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for uuid_blake3-0.1.0-cp38-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 31a6b324f20b1e578b788b5e314b6819c8ed53c65b0b37a1dcb2762a8e68dd60
MD5 93c7d69fee3e6d7e7ac03c82c0259b22
BLAKE2b-256 ecb603571cea5f5ad6ed8cb4ab4bdab7304a19fcdf84065f4d61e605a1506518

See more details on using hashes here.

File details

Details for the file uuid_blake3-0.1.0-cp38-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for uuid_blake3-0.1.0-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 88723ede326050033bc66a8f6cd887c61b7a9339faf96c417e4d8f40d3528472
MD5 1d7d3bb43a9fd4ecea4173c7ce861f48
BLAKE2b-256 d377dd391bb3cf8e5ea2228012e4ec4a49cfca835b273767f7fb44514230a6ab

See more details on using hashes here.

File details

Details for the file uuid_blake3-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for uuid_blake3-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 34635c5d23990e5d588332b4701153b9c3433f3e011c21e343a090458d008760
MD5 38d09665e2871eb12f9744428d2c5579
BLAKE2b-256 26ba5b79ade61ee0657d44df544a5f7b05352ec5f62b94945f649071a3ea936f

See more details on using hashes here.

File details

Details for the file uuid_blake3-0.1.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for uuid_blake3-0.1.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 ac045a7c84b14322df7d245f47111e2eef507d53e9907242cf387da44ea6fa1e
MD5 05c2c3eddbb0674685577c7a895e9c09
BLAKE2b-256 a02dda6d3d3300377df79b9e55fef12af3efc5fa67682f225d902b5c45430421

See more details on using hashes here.

File details

Details for the file uuid_blake3-0.1.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for uuid_blake3-0.1.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 885477290bde2e6faa3fe88f9a52bcf784645e9a0223b247a7a8cf2e9a14fc68
MD5 fffa2e4370a3b0369d1cf2c6fdc9bfe5
BLAKE2b-256 48516fb2d6e4e94dd316ff3b5a3aabb0559ab3453c15f968fda0f231647b8675

See more details on using hashes here.

File details

Details for the file uuid_blake3-0.1.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for uuid_blake3-0.1.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 ac2bc700e79f081793e38193b61c50e52dfda6826a89cfa737153731310d1f8a
MD5 2551c20bb8758f97a8054142242f1574
BLAKE2b-256 8900d92ba76aebcbf80704164bb833f131b420191e011ed6693ade028561f3cb

See more details on using hashes here.

File details

Details for the file uuid_blake3-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for uuid_blake3-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bbb59bfe2491b4b8d41f3a7e9ecc9a1a70851fc1868dcb98aa6a5445ed343066
MD5 f3445e8c6b26e95415442b6a72dde6b5
BLAKE2b-256 16f3a87fc40de8b0d83f89524df22cd3e0817ffa54206a36167c45090e2d8e5f

See more details on using hashes here.

File details

Details for the file uuid_blake3-0.1.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for uuid_blake3-0.1.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 fdc8a2b4e98e00352387c0fa21a354120453bc4b85bcc47c1410a5dcafa29b44
MD5 9125f775287ba3213e7e9134b59acbb5
BLAKE2b-256 5c7738b092c8efb6e82e27c9bff29c7b88868657e527527860b3c4749bb0124d

See more details on using hashes here.

File details

Details for the file uuid_blake3-0.1.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for uuid_blake3-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 307b0c4d373e45ff19dc6ce8482d75d39bff0c9448fee67323672c3785926edf
MD5 a47a8acbacb08cfbf539333c1c708046
BLAKE2b-256 32328486a13e9f0b7eb628b30e693c8f6ee80b7972013dfc743995fc79624299

See more details on using hashes here.

File details

Details for the file uuid_blake3-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for uuid_blake3-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2a06c1a29dcc76a4b6e071b0dcc6f05f5e192e5e118a0291472f1a774fd6d94a
MD5 3272786f8024a857b0d9381b764c03c4
BLAKE2b-256 7b29999bb6f33ed816a9e97303da1c2bd57e052a66374471a714206d878d2dbe

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