Skip to main content

hardguard25

Python reference implementation of HardGuard25 — an open standard for human-safe identifiers.

0 1 2 3 4 5 6 7 8 9 A C D F G H J K M N P R U W Y

HardGuard25 is a 25-character alphabet designed to exclude common visual confusables, including patterns relevant to dyslexia-sensitive workflows. It removes 11 letters associated with predictable confusion (I L O B S Z E T V X Q). When a letter and a digit compete for the same visual slot, the digit always wins. Comparative OCR and transcription error rates have not yet been established empirically.

Install

pip install hardguard25

Requires Python 3.9+.

Quickstart

from hardguard25 import generate, validate, normalize, check_digit, verify_check_digit

generate(8)                       # e.g. "AC3H7PUW"
generate(8, check_digit=True)     # e.g. "AC3H7PUWN"  (length+1)

validate("ac3h-7puw")             # True  (case and separators tolerated)
normalize("ac3h-7puw")            # "AC3H7PUW"

check_digit("AC3H7PUW")           # "N"
verify_check_digit("AC3H7PUWN")   # True

Normalization rejects empty and separator-only input. Validation returns False for it, and check-digit calculation rejects an empty payload.

API

Function Purpose
generate(length, *, check_digit=False) Cryptographically secure random ID using rejection sampling for uniform distribution
validate(s) True if s normalizes to a valid HardGuard25 ID; never raises
normalize(s) Trim, uppercase, strip - _ . and spaces; raises ValueError on invalid chars
check_digit(code) Mod-25 weighted check digit for manual-entry error detection
verify_check_digit(code) Strip last char, recompute, compare
ALPHABET "0123456789ACDFGHJKMNPRUWY"

Type hints and py.typed marker included.

Sizing

Each character carries log2(25) = 4.64 bits of entropy.

Length Bits Unique IDs Typical Use
4 18.6 390,625 Small inventory, tickets
5 23.2 9,765,625 Small business
6 27.9 244,140,625 Medium businesses
7 32.5 6.1 billion Large catalogs
8 37.2 152.6 billion Large systems
12 55.7 5.96 × 10¹⁶ Internal tokens
16 74.2 3.55 × 10²² Cross-system IDs
20 92.8 2.11 × 10²⁷ Public tokens
22 102.1 1.32 × 10³⁰ Internet-scale

Recommended defaults:

  • 16 for internal systems up to millions of IDs
  • 20 for public tokens or cross-org use
  • 22 for long-lived, internet-scale identifiers

See the spec for collision-bound tables.

Implementation guidance

For project integration guidance, see:

When NOT to Use HardGuard25

  • Cryptographic keys (use proper key derivation)
  • Blockchain consensus (use domain-specific formats)
  • Systems requiring global UUID guarantees (use UUIDv7 or ULID)
  • Machine-only contexts where no human ever sees the ID

Reference

License

MIT

Metadata

Release files for hardguard25 1.3.7

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

Source distribution (sdist)

Source distribution for hardguard25 1.3.7
File Size Uploaded
hardguard25-1.3.7.tar.gz 8.4 kB Details

Built distribution (wheel)

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

Total release size: 14.7 kB

Release files / hardguard25-1.3.7.tar.gz

Download URL hardguard25-1.3.7.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ee0eb70833b5e3da7ed45cebbbfba1974bf4a8a369b1eb692494e7fc2d6159c1
BLAKE2b-256 checksum
How to use checksums
4818273e8d410590d62527dc80275a12498435a0808c24a72f55aaa600d3aa06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / hardguard25-1.3.7-py3-none-any.whl

Download URL hardguard25-1.3.7-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15d6ca26531e373e146e3389203f84c4eda483248d733e2ae2e32b2bacf1ee73
BLAKE2b-256 checksum
How to use checksums
85d22e834c2356d8cf18041b56505a5bf5a719ca7547ab5de191a618fade8b42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

1.3.8

2 release files

This release

1.3.7 This release

2 release files

1.3.6

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.1

2 release files

1.3.0

2 release files

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