Skip to main content

IDCrockford

Crockford Base32 ID encoder/decoder with FastAPI dependency injection support for validation and generation of Crockford Base32 IDs.

idcrockford has 3 interfaces:

  • CLI
  • Library
  • FastAPI dependency

Installation

pip install idcrockford

or using uv:

uvx idcrockford

CLI

uvx idcrockford --help

usage: idcrockford [-h] [--checksum] [--split SIZE] [--padding] [--strict] {encode,decode,normalize,generate} [input]

Crockford Base32 Utility

positional arguments:
  {encode,decode,normalize,generate}
                        Operation to perform
  input                 Input to process. For encode: integer or string. For generate: size (optional)

options:
  -h, --help            show this help message and exit
  --checksum            Add/validate checksum symbol
  --split SIZE          Split encoded string with hyphens (chunk size, default: no splitting)
  --padding             Add padding characters (=) to output
  --strict              Strict mode for normalize command - error if normalization needed

Library

from idcrockford import Base32Crockford

crockford = Base32Crockford(
    checksum=True,
    split=4,
    padding=True,
)

# Encode and decode
crockford.encode(1234567890) # 14SC-0PJV
crockford.decode("14SC-0PJV") # 1234567890

# Generate
crockford.generate() # 16 random characters
crockford.generate(size=10) # 10 random characters
crockford.generate(size=10, checksum=True, split=4, padding=True) # 10 random characters with checksum, split and padding

# TODO: add normalize
crockford.normalize("14SC-0PJV") # 14SC0PJV

FastAPI Dependency

from fastapi import FastAPI, Depends
from idcrockford import CFIdentifierConfig

IdentifierConfig = CFIdentifierConfig(checksum=True, size=16)

app = FastAPI()

@app.get("/items/{id}")
def read_item(id: str = Depends(IdentifierConfig.validate)):
    return {"id": id}

@app.post("/items/")
def create_item(id: str = Depends(IdentifierConfig.generate)):
    return {"id": id}

Roadmap

  • Add normalize method to CFIdentifierConfig
  • Support Pydantic custom type for Crockford Base32 ID validation and generation

License

MIT

Other packages

Metadata

Release files for idcrockford 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for idcrockford 0.1.2
File Size Uploaded Provenance Actions
idcrockford-0.1.2.tar.gz 5.2 kB Without provenance Details for idcrockford-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for idcrockford 0.1.2
File Interpreter ABI Platform Actions
idcrockford-0.1.2-py3-none-any.whl Python 3 none any Details for idcrockford-0.1.2-py3-none-any.whl

Total release size: 11.1 kB

Release files / idcrockford-0.1.2.tar.gz

Download URL idcrockford-0.1.2.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e222fefcb7fb7fcdb432e2d2e4a8c8f1afa0a6f14d585ebfd8a39cf05423c1b1
BLAKE2b-256 checksum
How to use checksums
494d611e6e64790d7141f880300613d9cc24e5f2034fe690e8c336dc482d6f94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.4

Release files / idcrockford-0.1.2-py3-none-any.whl

Download URL idcrockford-0.1.2-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9df943e5d6e11f1947c810943fbbca6afe3975dc3841202eaf31bd439611f9bf
BLAKE2b-256 checksum
How to use checksums
99b052637c21f1c43e0fbb0184842f12e8d49d510a9a128f377b4df6601a7cec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.4

Security for idcrockford 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page