Skip to main content

A tiny, zero-dependency Python library for generating and converting UUIDs to Base58-encoded strings

Project description

Base58UUID (Python版)

UUIDをBase58エンコード/デコードするPythonライブラリです。短く、URLセーフな文字列としてUUIDを表現できます。

インストール

pipを使用してインストールできます:

pip install base58uuid

必要条件

  • Python 3.7以上

使用方法

基本的な使い方

from base58uuid import Base58UUID

# 新しいUUIDを生成
b58 = Base58UUID()
uuid = b58.get_uuid()  # 例: "f4b247fd-1f87-45d4-aa06-1c6fc0a8dfaf"

# 既存のUUIDをBase58エンコード
b58 = Base58UUID('f4b247fd-1f87-45d4-aa06-1c6fc0a8dfaf')
encoded = b58.encode()  # 例: "XDY9dmBbcMBXqcRvYw8xJ2"

# Base58文字列をUUIDにデコード
decoded = b58.decode('XDY9dmBbcMBXqcRvYw8xJ2')  # 元のUUIDに戻る

エラーハンドリング

try:
    # 無効なUUID形式
    b58 = Base58UUID('invalid-uuid')
except ValueError as e:
    # "Invalid UUID format" エラー
    pass

try:
    # 無効なBase58文字列
    b58 = Base58UUID()
    b58.decode('invalid')
except ValueError as e:
    # "Invalid Base58 character" エラー
    pass

開発

セットアップ

# 仮想環境の作成と有効化
python -m venv venv
source venv/bin/activate  # Linuxの場合
# または
.\venv\Scripts\activate  # Windowsの場合

# 依存関係のインストール
pip install -e ".[dev]"

# テストの実行
pytest tests/

テスト

以下のテストケースが含まれています:

  • 既知のUUIDのエンコード
  • ハイフンなしUUIDのエンコード
  • Base58文字列のデコード
  • 無効な入力のエラーハンドリング
  • エンコード/デコードの一貫性
  • 複数回エンコードの結果の一貫性

ライセンス

MITライセンスの下で公開されています。詳細はLICENSEファイルを参照してください。

貢献

  1. このリポジトリをフォーク
  2. 新しいブランチを作成 (git checkout -b feature/amazing-feature)
  3. 変更をコミット (git commit -m 'Add some amazing feature')
  4. ブランチにプッシュ (git push origin feature/amazing-feature)
  5. プルリクエストを作成

作者

  • Yoshitake Hatada (@htpboost)

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

base58uuid-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

base58uuid-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: base58uuid-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for base58uuid-0.1.0.tar.gz
Algorithm Hash digest
SHA256 de25d3cebfd9fee26781f09165076f87c4bae6d34107ebdc5afdcb6e5a406dc2
MD5 e56626e494c486784cfff6e022f83281
BLAKE2b-256 17da40ab32119ca91dca3e35d0d744f20fcdfd75ea53e82f1c8d870311ac935b

See more details on using hashes here.

File details

Details for the file base58uuid-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: base58uuid-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for base58uuid-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 141458a7dcaef7161bfacb9e11ac1ace1bb1db19395d0692fbef358afbe5ccd6
MD5 86a3f313c16babf198a362be55619c7e
BLAKE2b-256 e3bf5c6b9a9aff101e986a5ebd5832191aa21c7a2fca452171d2547039cacc77

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