Skip to main content

HCE

Lossless, pronounceable, encrypted codec for any identifier — reversible, format-preserving, human-readable.

Install

pip install hce

Quick Start

import hce

h = hce.Hce(
    key=b"32-byte-secret-key-here-xxxxxx!!",
    level="universal",
    mode="sealed",
)

encoded = h.encode(bytes(range(16)))
decoded = h.decode(encoded)
print(decoded.hex())

API

Constructor

hce.Hce(
    key: bytes | None = None,
    level: str = "universal",
    mode: str = "sealed",
    bit_width: int = 128,
) -> Hce
Param Type Description
key bytes | None Encryption key bytes. None for plain mode.
level str "universal", "eu", "en", "numeric", "ko"
mode str "sealed", "open", "plain"
bit_width int 16–128. Default 128.

Core Methods

h.encode(data: bytes) -> str
h.decode(input: str) -> bytes
h.recover(input: str) -> bytes
Method Description
encode(data) Encrypt + encode bytes to HCE string.
decode(input) Decode + decrypt HCE string to bytes. Raises ValueError on integrity failure.
recover(input) Attempt self-recovery on corrupted input. Returns recovered bytes or raises ValueError.

Domain Configuration

h.with_bit_width(bits: int) -> Hce
h.with_modulus(modulus: int) -> Hce
h.with_cipher(kind: str, key: bytes | None = None) -> Hce
Method Description
with_bit_width(bits) Set cipher domain bit width (16-128).
with_modulus(n) Set modulus domain. Must be ≥ 2.
with_cipher(kind, key?) Select cipher: "feistel" (default, 8-round HMAC-SHA256) or "shuffle" (4-round lightweight).

Output Configuration

h.with_case("upper" | "lower") -> Hce
h.with_check_syllables(n: int) -> Hce
h.with_separator(sep: str) -> Hce
Method Description
with_case(case) Output case. Default "upper".
with_check_syllables(n) Number of HMAC check syllables (1-8). Default 1.
with_separator(sep) Chunk separator character. Default "-".

Chunking

h.with_chunk_none() -> Hce
h.with_chunk_fixed(char_size: int) -> Hce
h.with_chunk_pattern(pattern: list[int]) -> Hce
Method Description
with_chunk_none() No separators.
with_chunk_fixed(n) Chunk every n characters.
with_chunk_pattern([3,3,4,4]) Custom syllable-per-chunk pattern.

Timestamp

h.with_timestamp_config(epoch_ms: int, granularity: str) -> Hce
Param Description
epoch_ms Unix epoch in milliseconds.
granularity "second" | "minute" | "hour" | "day" | "week" | "month"

Levels

Each level uses a different phoneme set:

Level Onset Vowel+Nucleus Description
universal 35 20 Default phoneme inventory
eu 35 20 Reserved for European variants
en 35 20 Reserved for English variants
numeric 35 20 Numeric-style
ko 35 20 Korean-style Romanization

Modes

Mode Check Purpose
sealed HMAC-SHA256 Full confidentiality + integrity
open HMAC-SHA256 Timestamp prefix for sorting
plain CRC No encryption, CRC integrity only

Development

cd crates/hce-py
python -m venv .venv
source .venv/bin/activate
pip install maturin pytest
maturin develop
pytest tests/

License

MIT

Metadata

Release files for hce 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 hce 0.1.2
File Size Uploaded
hce-0.1.2.tar.gz 40.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for hce 0.1.2
File
hce-0.1.2-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
hce-0.1.2-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
hce-0.1.2-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
hce-0.1.2-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
hce-0.1.2-cp38-abi3-manylinux_2_34_x86_64.whl CPython 3.8 abi3 Linux glibc 2.34+ x86-64 Details
hce-0.1.2-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details

Total release size: 1.2 MB

Release files / hce-0.1.2.tar.gz

Download URL hce-0.1.2.tar.gz
Size 40.9 kB
Tags Source
SHA-256 checksum
How to use checksums
866498039084e8f99540c1c5b52c0a3682c1a339365084bb05123b0bc8ba2ddd
BLAKE2b-256 checksum
How to use checksums
13f455507e4211ad237fdaf921954fbdfbec79890820ed830b31efbe74d4b08a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / hce-0.1.2-cp312-cp312-win_amd64.whl

Download URL hce-0.1.2-cp312-cp312-win_amd64.whl
Size 130.5 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
dc91e742c86566d7b9d85eb55b8444fb387ab41467c684e5257b3318028eafae
BLAKE2b-256 checksum
How to use checksums
b073e18a4134fc5a80d5564eb575af2e959fc4c99c4426f970d23b5fb62baac0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / hce-0.1.2-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL hce-0.1.2-cp312-cp312-manylinux_2_34_x86_64.whl
Size 225.1 kB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
13e4afea281233066e13af2f46a133752500d9b98714dbb1cd653e9efbecbb32
BLAKE2b-256 checksum
How to use checksums
3dfe87de01bf3c328fb5797110940f897e13864f7fc0c1983668dd47dbc6ef0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / hce-0.1.2-cp312-cp312-macosx_11_0_arm64.whl

Download URL hce-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Size 194.7 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ab258e4e5fedca7739f0e371a581fd5a241003b1d5541df4239681e412185f62
BLAKE2b-256 checksum
How to use checksums
65d66a09dcada865e90fc0910318055f2e205581027e28eacd0a526196b9989f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / hce-0.1.2-cp38-abi3-win_amd64.whl

Download URL hce-0.1.2-cp38-abi3-win_amd64.whl
Size 135.3 kB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f4f869b8536eba0382b79947352eb3ba00016b90b87079d28383772a824dbd4d
BLAKE2b-256 checksum
How to use checksums
ee705151aa974871953c65b14e706e98fb9542364060bf2fb73a5b8d0ef644a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / hce-0.1.2-cp38-abi3-manylinux_2_34_x86_64.whl

Download URL hce-0.1.2-cp38-abi3-manylinux_2_34_x86_64.whl
Size 231.2 kB
Tags CPython 3.8 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
70ac58246ec7ca30346b5307b8968c8fac484e26bdd96dcb091a67a9b008020b
BLAKE2b-256 checksum
How to use checksums
8154a3370a8f02c8efdfcec68c59e84fd2fefee049283c284e05fa0c8f56f09c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / hce-0.1.2-cp38-abi3-macosx_11_0_arm64.whl

Download URL hce-0.1.2-cp38-abi3-macosx_11_0_arm64.whl
Size 199.7 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9c2f8423aa36ceb6b12318aefebb31a455bdef720a7811998ea9423e9cca0795
BLAKE2b-256 checksum
How to use checksums
58b860a0ace13abe5b9fd20d894e01b1be5ee9c3c7242e76a95fe46bed6a12f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release history Release notifications | RSS feed

This release

0.1.2 This release

7 release files

0.1.0

3 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