baseh
Python implementation of the baseH codec. Encodes an internal integer ID as
a checksummed, optionally permuted human-readable reference code. Implements
the normative spec in ../spec/IMPLEMENTATION_CODEC.md and passes the
frozen cross-language vectors in ../vectors/.
Zero runtime dependencies. HMAC-SHA-256 comes from the standard library.
Install
pip install ./python
Or run in place without installing:
PYTHONPATH=python/src python3 -c "import baseh"
Usage
from baseh import Baseh, BasehError, baseh_medium_v1
codec = Baseh(baseh_medium_v1())
code = codec.encode(123456789)
print(code) # fixed-length, checksummed code
result = codec.decode(code.lower()) # case-insensitive
print(result.id) # 123456789
print(result.canonical_code) # canonical rendering
print(result.corrected) # False (input differed only in case)
# Assisted correction over spoken-confusion pairs (B/D, P/T, ...):
fixed = codec.decode(
code,
try_correction=True,
confusion_profile="light",
)
# Non-throwing validation for user input:
check = codec.validate("0000000")
print(check) # {"valid": False, "reason": "INVALID_CHECKSUM"}
print(codec.capacity()) # 481890304
Errors raise BasehError with a .code attribute, one of:
INVALID_PROFILE, OUT_OF_RANGE, PERMUTATION_FAILURE, INVALID_LENGTH,
INVALID_CHARACTER, INVALID_CHECKSUM, AMBIGUOUS_INPUT,
TOO_MANY_CANDIDATES, BLOCKED_CODE.
Frozen tiers
Four frozen profiles, each 6 body symbols and case-insensitive, built from the full alphanumeric set with cumulative visual and spoken strips:
| Tier | Helper | Symbols | Checksum | Capacity |
|---|---|---|---|---|
| Minimum | baseh_minimum_v1() |
36 | none | 2,176,782,336 |
| Light | baseh_light_v1() |
31 | 1 | 887,503,681 |
| Medium | baseh_medium_v1() |
28 | 1 | 481,890,304 |
| Heavy | baseh_heavy_v1() |
26 | 1 | 308,915,776 |
Medium is the default. All four keep the typed O/I/L aliases where possible
and run the default profanity blocklist. Minimum also uses a hyphen
delimiter (XXX-XXX); the rest have none.
Each helper returns a freshly-built mutable profile dict on every call, so callers can load a default and modify it:
profile = baseh_medium_v1()
profile["checksumLength"] = 2
codec = Baseh(profile)
Permuted variants
The _p variants are identical to their tier but enable feistel-v1
permutation and require caller-supplied key material:
from baseh import Baseh, baseh_medium_p_v1
key = bytes.fromhex("746573742d6f6e6c792d6b65792d6d6174657269616c2d30303031")
codec = Baseh(baseh_medium_p_v1(key, key_id="my-app-01")) # rounds defaults to 8
Available as baseh_minimum_p_v1, baseh_light_p_v1, baseh_medium_p_v1
and baseh_heavy_p_v1.
Profanity safety (spec 18)
All frozen tiers run the default blocklist. Profiles accept a profanity
field to change that:
# Block specific words (substrings of the raw code) at encode time:
profile = baseh_medium_v1()
profile["profanity"] = {"mode": "blocklist", "extraWords": ["QQQQ"]}
codec = Baseh(profile)
# codec.encode(id) raises BasehError(code="BLOCKED_CODE") on a match.
# Or remove vowels from both alphabets entirely:
profile["profanity"] = {"mode": "no-vowels"}
Tests
cd python
PYTHONPATH=src python3 -m unittest discover -s tests -v
Metadata
Release files for baseh 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| baseh-1.1.0.tar.gz | 19.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| baseh-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.9 kB
Release files / baseh-1.1.0.tar.gz
| Download URL | baseh-1.1.0.tar.gz |
|---|---|
| Size | 19.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c95dc62245e92d5aa761a7a37f78823baab1d41dc37f35d01d5693a7407d784
|
|
BLAKE2b-256 checksum How to use checksums |
69a8db7ee3d0f3e4f320cdc342f5a2bad8850bb7a3c81d076c259ec1a392f306
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 1, 2026.
Transparency logRelease files / baseh-1.1.0-py3-none-any.whl
| Download URL | baseh-1.1.0-py3-none-any.whl |
|---|---|
| Size | 15.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0fb4c3b592ce089fc8bbaa602caa018153e08717e08fc5f89787af9dc0280e31
|
|
BLAKE2b-256 checksum How to use checksums |
d8d9cad2e8dbee7b174f6c517408269710a3cd448196e480754df64fe92dd617
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 1, 2026.
Transparency log