25-digit case-insensitive UUID encoding
Project description
Uuid25: 25-digit case-insensitive UUID encoding
Uuid25 is an alternative UUID representation that shortens a UUID string to just 25 digits using the case-insensitive Base36 encoding. This library provides functionality to convert from the conventional UUID formats to Uuid25 and vice versa.
from uuid25 import Uuid25
# convert from/to string
a = Uuid25.parse("8da942a4-1fbe-4ca6-852c-95c473229c7d")
assert a.value == "8dx554y5rzerz1syhqsvsdw8t"
assert a.to_hyphenated() == "8da942a4-1fbe-4ca6-852c-95c473229c7d"
# convert from/to 128-bit byte array
b = Uuid25.from_bytes(bytes([0xFF] * 16))
assert b.value == "f5lxx1zz5pnorynqglhzmsp33"
assert all([x == 0xFF for x in b.to_bytes()])
# convert from/to other popular textual representations
c = [
Uuid25.parse("e7a1d63b711744238988afcf12161878"),
Uuid25.parse("e7a1d63b-7117-4423-8988-afcf12161878"),
Uuid25.parse("{e7a1d63b-7117-4423-8988-afcf12161878}"),
Uuid25.parse("urn:uuid:e7a1d63b-7117-4423-8988-afcf12161878"),
]
assert all([x.value == "dpoadk8izg9y4tte7vy1xt94o" for x in c])
d = Uuid25.parse("dpoadk8izg9y4tte7vy1xt94o")
assert d.to_hex() == "e7a1d63b711744238988afcf12161878"
assert d.to_hyphenated() == "e7a1d63b-7117-4423-8988-afcf12161878"
assert d.to_braced() == "{e7a1d63b-7117-4423-8988-afcf12161878}"
assert d.to_urn() == "urn:uuid:e7a1d63b-7117-4423-8988-afcf12161878"
# convert from/to standard uuid module's UUID value
import uuid
uuid_module = uuid.UUID("f38a6b1f-576f-4c22-8d4a-5f72613483f6")
e = Uuid25.from_uuid(uuid_module)
assert e.value == "ef1zh7jc64vprqez41vbwe9km"
assert e.to_uuid() == uuid_module
# generate UUIDv4 in Uuid25 format (backed by uuid module)
import uuid25
print(uuid25.gen_v4()) # e.g., "99wfqtl0z0yevxzpl4hv2dm5p"
License
Licensed under the Apache License, Version 2.0.
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
uuid25-0.1.3.tar.gz
(7.5 kB
view details)
Built Distribution
File details
Details for the file uuid25-0.1.3.tar.gz
.
File metadata
- Download URL: uuid25-0.1.3.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.2 Darwin/23.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76cab22cd2226f9dfa51b8b043351008d72c8578f3cb94c5571ff6c1310e9419 |
|
MD5 | 3c1a39b03db0f61e712f09923b15badb |
|
BLAKE2b-256 | bfc85b8a48f4d0a527967b3ee2cd883e847ee1febd31efe4a8635eba2bec888c |
File details
Details for the file uuid25-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: uuid25-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.2 Darwin/23.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bddf30d8de67f4ab96eb71fbf983bf1f8bd8df86959828f875430a2ee274801 |
|
MD5 | 97eba00b1bad12af50e616149ac8b677 |
|
BLAKE2b-256 | 90858b1bedd7a9ddce5b1e9b5d94425bafec87506aad898a39bbf6d6d05215c3 |