Skip to main content

25-digit case-insensitive UUID encoding

Project description

Uuid25: 25-digit case-insensitive UUID encoding

PyPI License

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.4.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

uuid25-0.1.4-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file uuid25-0.1.4.tar.gz.

File metadata

  • Download URL: uuid25-0.1.4.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Darwin/24.2.0

File hashes

Hashes for uuid25-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3a3a39284475815cebd8b17cd68619e45b3cceac178b1e2e0c03d69a52af1a52
MD5 bde31b9d611276af6ce0d47873c1b96f
BLAKE2b-256 7ef5bfe37879bfbe54bec8acc328c19380dfcfd477fc79352d2a2d2e96dff500

See more details on using hashes here.

File details

Details for the file uuid25-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: uuid25-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Darwin/24.2.0

File hashes

Hashes for uuid25-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2bcae38e4ab6d1df33a32df5a23679565a099895795df4310c02aad3521e537a
MD5 7ce01e7a978c38dcb47bb0d1a4241ec2
BLAKE2b-256 6adbcf5ae032afcbedbeb6cfea84a5aa316ac67b8d8dae5bfce5ab66b9283435

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