No project description provided
Project description
uuid_blake3
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 UUIDname: 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 UUIDname: Name/identifier within the namespacemetadata: 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
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 Distributions
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 uuid_blake3-0.2.0.tar.gz.
File metadata
- Download URL: uuid_blake3-0.2.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a749fe05466c54f514cb0df13c62c9cf2b15d1c4f104682ec7c8f94b60714f2a
|
|
| MD5 |
1bdf2aed2174e042d8f62da3f1ff7bbe
|
|
| BLAKE2b-256 |
e46dfc07bbfb1841f8fff15f1c1f44e41024493fcd27aa6c2ef0c70e6ee1ec44
|
File details
Details for the file uuid_blake3-0.2.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: uuid_blake3-0.2.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 140.4 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
840fccdbfd0350e4cb34dadf27efb456fc7d914e76c668aab7dac30890bce0f8
|
|
| MD5 |
14d544398d3907c9230ea385139aae0c
|
|
| BLAKE2b-256 |
a543f08779b2939cd687e8d4a88eaacaedd5e30c13a10771089542933d22aa4e
|
File details
Details for the file uuid_blake3-0.2.0-cp38-abi3-win32.whl.
File metadata
- Download URL: uuid_blake3-0.2.0-cp38-abi3-win32.whl
- Upload date:
- Size: 156.9 kB
- Tags: CPython 3.8+, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c183a09663beb6748b0e836a1b0548d45a1b4d858180c64f08b0a4efa198cedc
|
|
| MD5 |
fddf570afa0f462f93f0b76de9cafcad
|
|
| BLAKE2b-256 |
9926e55ac097987afdf38a0834a352d9413afd31b6f50f6fbdc1e70e7e12141e
|
File details
Details for the file uuid_blake3-0.2.0-cp38-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: uuid_blake3-0.2.0-cp38-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 447.9 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da45e4834d1238446dde56c91754660848ecfdce92ba8723e632a2f7b056f96b
|
|
| MD5 |
8df1f3e248d74d5cb87be4484fa00c51
|
|
| BLAKE2b-256 |
4ccd7c778f586aec8a8bd1262afcc1c1ef46ed4fd594d25b691bd663d36ae6b9
|
File details
Details for the file uuid_blake3-0.2.0-cp38-abi3-musllinux_1_2_i686.whl.
File metadata
- Download URL: uuid_blake3-0.2.0-cp38-abi3-musllinux_1_2_i686.whl
- Upload date:
- Size: 509.0 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aecc98b65a4ff4e3d57abbc3dbaa345d622c3e217d0a993064b4504abfde474d
|
|
| MD5 |
7b24208b41e25c4893652c95b6e30ad6
|
|
| BLAKE2b-256 |
907d9305b8f655a9912695e48003624e60f1666c328a7fb2551824d128150e5f
|
File details
Details for the file uuid_blake3-0.2.0-cp38-abi3-musllinux_1_2_armv7l.whl.
File metadata
- Download URL: uuid_blake3-0.2.0-cp38-abi3-musllinux_1_2_armv7l.whl
- Upload date:
- Size: 533.8 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3d3e79f12b3f86551d8e8d2c9de272198814b17d01cf5f045321a21cbdbb494
|
|
| MD5 |
902351a81458b909f7bf38e938679531
|
|
| BLAKE2b-256 |
a47a32a5bae57b823426ea2d67697fbbab18d503e482c772c21f7bacb48c9441
|
File details
Details for the file uuid_blake3-0.2.0-cp38-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: uuid_blake3-0.2.0-cp38-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 446.3 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9dc9b0fb8fa82337df9551282fe18339cd67bf88e2590396c8c1661cf6a40916
|
|
| MD5 |
6838a64df8d3c2f003ac56b09a75dd74
|
|
| BLAKE2b-256 |
a42a09acb5a24a3d178df24a1d5afe2dee6de80d0dd7b1147de20b99a8b56d9f
|
File details
Details for the file uuid_blake3-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: uuid_blake3-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 276.8 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87d576d4cc72be8b00e69fc07bb25cc3a479b8b93c9b37e4c0a402a78b8d3004
|
|
| MD5 |
f7f61f6a907dde6093fb546f4ea87571
|
|
| BLAKE2b-256 |
6024bd748b384b8eac7f332d65aa445ef30d8362a8eb01fa7b3b1da8f7c27f8e
|
File details
Details for the file uuid_blake3-0.2.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: uuid_blake3-0.2.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 292.3 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee58e63a3df5db75fbb378ad1c51c6911abdad3074fe355adbded35c7fbdbfc4
|
|
| MD5 |
892db6e66db372f7451ee0c28738832e
|
|
| BLAKE2b-256 |
e677fa3b4030cc51849dadf1ab01081a2b022cb3614946e58845648022a3b5e7
|
File details
Details for the file uuid_blake3-0.2.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: uuid_blake3-0.2.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 401.5 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84070e1b3b2c8af141a49cbb622d22043ad04cb7e87874dfdc1afe6e0c101f7c
|
|
| MD5 |
9a2a8dd31ecffcc10bf501b08925639d
|
|
| BLAKE2b-256 |
87f43a7f25a4bb5b643a213d6d413bb736d9225e5239faa147fce1894506d0de
|
File details
Details for the file uuid_blake3-0.2.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: uuid_blake3-0.2.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 270.8 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2329919e79c8090ca653d0ae68113ab194086654766e588a8d43dbddba57153
|
|
| MD5 |
6b10967fc49f04fb1c11865692a59643
|
|
| BLAKE2b-256 |
24eea64fa878288a60aa5c6c850d0c7a2742f4a0a4af006ce9529414edb99550
|
File details
Details for the file uuid_blake3-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: uuid_blake3-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 268.1 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b660252c9f04e6107059b2f5a3e9c33a3c710285cbf8ab1f79fa9f8abc497de
|
|
| MD5 |
56c66e1c789f5efd8d89fb53e2008c13
|
|
| BLAKE2b-256 |
fb50b9265332977f9271cf62c2df2bbe083037c1ba0676ce55f0ae448549d91f
|
File details
Details for the file uuid_blake3-0.2.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl.
File metadata
- Download URL: uuid_blake3-0.2.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl
- Upload date:
- Size: 329.8 kB
- Tags: CPython 3.8+, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
740c560055f73b6c83ac8b7be18118cfa96b12df17e7fa5d70cfe876eb564a60
|
|
| MD5 |
5a467d3e36614b92a6525c256d56b2d8
|
|
| BLAKE2b-256 |
741c94768360375041d6c00a538bda96e06167985444a30f176484b8b7b47cda
|
File details
Details for the file uuid_blake3-0.2.0-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: uuid_blake3-0.2.0-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 239.1 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a36df07dc2052b3de782aaa3e77f7d942f921ff0f17b023c90c54b5bbead2f8
|
|
| MD5 |
303f1898bc14e4ee5a6c2689776724d0
|
|
| BLAKE2b-256 |
ec0ce472538323f11d5b1507da0a0ea7f030fc7556a6327532792f751c431ffe
|
File details
Details for the file uuid_blake3-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: uuid_blake3-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 255.8 kB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdbf6068bf188df027ccd05c92ae56c57d6781e557e915386a7aedeada5144db
|
|
| MD5 |
4fa022d5f60065cbba0636fcb7509f82
|
|
| BLAKE2b-256 |
80111d3492f35f6195cfa6e819b6aa8b95a652aa47db42304cf91ea3991fec99
|