Metadata-Version: 2.3
Name: crockford-id-generator
Version: 0.1.0
Summary: Secure random identifiers encoded in Crockford Base32 with modulo-37 checksums
Keywords: identifier,crockford,base32,checksum
Author: Rodolfo De Chiara
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.13
Description-Content-Type: text/markdown

# Crockford ID Generator

Generate identifiers from 128 cryptographically secure random bits, encoded as
26 Crockford Base32 characters followed by a modulo-37 checksum character.
Requires Python 3.13 or newer and has no runtime dependencies.

The distribution is named `crockford-id-generator`; the Python import is
`id_generator`.

## Install and use

Install from a checkout into your active environment:

```sh
uv pip install .
```

Generate an ID and verify its checksum:

```python
from id_generator import generate_random_id, is_identifier_checksum_valid

identifier = generate_random_id()
assert is_identifier_checksum_valid(identifier)
assert not is_identifier_checksum_valid("10U")  # The correct checksum for "10" is "*".
```

`is_identifier_checksum_valid` returns `False` for malformed input or a mismatched checksum.
It accepts lowercase letters, hyphens, and Crockford's equivalent characters
(`O` for `0`, `I` or `L` for `1`). It verifies the checksum without enforcing
the length or bit size used by `generate_random_id`.

## Develop

Use [uv](https://docs.astral.sh/uv/) to install the package and its locked
development tools. Ruff handles linting and formatting; ty checks the library's
types. Tests use Python's standard library.

```sh
uv sync --locked
uv run --locked ruff check .
uv run --locked ruff format --check .
uv run --locked ty check src
uv run --locked python -m unittest discover -s tests -v
```

Apply formatting with `uv run ruff format .`. Commit `uv.lock` so contributors
use the same tool versions.

## Build

The build backend is Astral's `uv_build`. Build a source distribution and a
wheel with:

```sh
uv build --no-sources
```

Artifacts appear in `dist/`. Install the wheel into a separate environment to
check the distribution without relying on the editable development install:

```sh
uv venv /tmp/crockford-id-generator-release-check
uv pip install --python /tmp/crockford-id-generator-release-check/bin/python dist/crockford_id_generator-*.whl
/tmp/crockford-id-generator-release-check/bin/python -I -c 'from id_generator import generate_random_id, is_identifier_checksum_valid; assert is_identifier_checksum_valid(generate_random_id())'
```

## Publish

Publish under the distribution name `crockford-id-generator`. The Python import
stays `id_generator` because the module name is configured explicitly. Choose
and record a license before distributing the project publicly.

For later releases, update the version with `uv version --bump patch` (or set
an exact version). Use a fresh output directory for each release so older
artifacts are not accidentally uploaded:

```sh
uv build --no-sources --out-dir dist/release
```

Set `UV_PUBLISH_TOKEN` securely in your environment to the destination
repository's API token. To upload to the configured TestPyPI index:

```sh
uv publish --index testpypi dist/release/crockford_id_generator-*
```

To upload to PyPI:

```sh
uv publish dist/release/crockford_id_generator-*
```

For another Python package repository, use its upload endpoint (which may
differ from its package index URL):

```sh
uv publish --publish-url https://packages.example.com/legacy/ dist/release/crockford_id_generator-*
```

See [Astral's publishing guide](https://docs.astral.sh/uv/guides/package/)
for authentication and named-index configuration.
