Skip to main content

High-performance Base58-encoded UUID library for Python

Project description

B58UUID for Python

PyPI version Python versions License: MIT Tests

Base58-encoded UUID library for Python with zero dependencies.

Why This Library?

  • Compact: 22 characters instead of 36
  • URL-safe: No special characters that need escaping
  • Unambiguous: Uses Bitcoin's Base58 alphabet (excludes 0, O, I, l)
  • Fast: Optimized encoding/decoding algorithms
  • Safe: Comprehensive error handling with overflow protection
  • Zero dependencies: Uses only Python standard library
  • Type hints: Full type annotation support
  • Python 3.8+: Compatible with Python 3.8 and higher

Installation

pip install b58uuid

Usage

import b58uuid

# Generate a new UUID
b58 = b58uuid.generate()
print(b58)  # Output: 3FfGK34vwMvVFDedyb2nkf

# Encode existing UUID
encoded = b58uuid.encode('550e8400-e29b-41d4-a716-446655440000')
print(encoded)  # Output: BWBeN28Vb7cMEx7Ym8AUzs

# Decode back to UUID
uuid_str = b58uuid.decode('BWBeN28Vb7cMEx7Ym8AUzs')
print(uuid_str)  # Output: 550e8400-e29b-41d4-a716-446655440000

API

Functions

  • generate() -> str - Generate a new random UUID and return Base58 encoding
  • encode(uuid_str: str) -> str - Encode UUID string to Base58
  • decode(b58_str: str) -> str - Decode Base58 string to UUID

Exceptions

  • ValueError - Raised for invalid input or overflow

Features

  • Zero dependencies (uses only Python standard library)
  • Always produces exactly 22 characters
  • Uses Bitcoin Base58 alphabet (no 0, O, I, l)
  • Thread-safe operations
  • Type hints support
  • Full error handling with overflow protection

Testing

# Run tests
python -m pytest tests/ -v

# Run tests with coverage
python -m pytest tests/ --cov=b58uuid --cov-report=html

Development

Requirements

  • Python 3.8 or higher
  • pytest (for testing)

Building from Source

# Clone the repository
git clone https://github.com/b58uuid/b58uuid-py.git
cd b58uuid-py

# Install in development mode
pip install -e ".[dev]"

# Run tests
python -m pytest tests/ -v

# Build package
python -m build

For detailed contribution guidelines, see CONTRIBUTING.md.

License

MIT License - see LICENSE file for details.

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

b58uuid-1.0.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

b58uuid-1.0.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file b58uuid-1.0.0.tar.gz.

File metadata

  • Download URL: b58uuid-1.0.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for b58uuid-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d5eca8b1eea85a93080b7a8346e6202d8447136811ca113e9efd9d0d87200b90
MD5 5229303ce085b30f5a45c1cef2f9ca72
BLAKE2b-256 df672c4af90aa8113ef0a44f0b255ffd8c24d76005ad0cca529887ec19c75552

See more details on using hashes here.

File details

Details for the file b58uuid-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: b58uuid-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for b58uuid-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7b3fe59d8363125a3ac0f97cde72e4249df099cb72493e49dbf5c18e767e0a4
MD5 9e160816258d3b9d239537665d674319
BLAKE2b-256 d941e0a1699e4286662aab0f3407b7412e24def674df61fe2b6eb154ea5d1b9c

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