Python bindings for Hexahexacontadecimal (base66) encoding
Project description
Python bindings for the k-hhc (Hexahexacontadecimal) C++ library.
This project is intended to be an exploration in creating performant, secure, and portable algorithms, while also being a learning experience for me. Take it with a grain of salt.
Inspired by hexahexacontadecimal by Alexander Ljungberg
Installation
Method 1: Using CMake (recommended for development)
# Clone the repository
git clone https://github.com/kirbyevanj/k-hhc.git
cd k-hhc
# From the root directory
mkdir build && cd build
cmake .. -DHHC_BUILD_PYTHON=ON
make
# The Python module will be in build/python/
Method 2: Using setuptools
# From the python directory
cd python
pip install .
# Or for development
pip install -e .
Requirements
- Python 3.6+
- pybind11
- C++23 compatible compiler (clang++ recommended)
Usage
Basic Example
import k_hhc
# Encode a 32-bit value
value = 424242
padded = k_hhc.encode_padded_32bit(value) # Returns: "--.TNv"
unpadded = k_hhc.encode_unpadded_32bit(value) # Returns: ".TNv"
# Decode a string
decoded = k_hhc.decode_32bit(".TNv") # Returns: 424242
# 64-bit operations
big_value = 9876543210
padded64 = k_hhc.encode_padded_64bit(big_value) # Returns: "-----5tVfK4"
unpadded64 = k_hhc.encode_unpadded_64bit(big_value) # Returns: "5tVfK4"
decoded64 = k_hhc.decode_64bit("5tVfK4") # Returns: 9876543210
Error Handling
import k_hhc
try:
# Invalid characters
k_hhc.decode_32bit("INVALID!")
except ValueError as e:
print(f"Invalid string: {e}")
try:
# Value exceeds bounds
k_hhc.decode_32bit("1QLCp2") # Exceeds UINT32_MAX
except OverflowError as e:
print(f"Value too large: {e}")
API Reference
Functions
encode_padded_32bit(value: int) -> str: Encode a 32-bit integer to a padded 6-character stringencode_unpadded_32bit(value: int) -> str: Encode a 32-bit integer to an unpadded stringdecode_32bit(encoded: str) -> int: Decode a string to a 32-bit integerencode_padded_64bit(value: int) -> str: Encode a 64-bit integer to a padded 11-character stringencode_unpadded_64bit(value: int) -> str: Encode a 64-bit integer to an unpadded stringdecode_64bit(encoded: str) -> int: Decode a string to a 64-bit integer
Constants
HHC_32BIT_ENCODED_LENGTH: Length of padded 32-bit encoded strings (6)HHC_64BIT_ENCODED_LENGTH: Length of padded 64-bit encoded strings (11)ALPHABET: The HHC alphabet string
Exceptions
ValueError: Raised when decoding a string with invalid charactersOverflowError: Raised when decoding a string that exceeds the bit bounds
Examples
See the examples/ directory for complete examples:
encode_example.py: Demonstrates encoding functionalitydecode_example.py: Demonstrates decoding with error handling and round-trip tests
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file k_hhc-1.0.6.tar.gz.
File metadata
- Download URL: k_hhc-1.0.6.tar.gz
- Upload date:
- Size: 21.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
549648af0fcc23826e25a99ae129085e82fa54ead25def11f79d4da76952526a
|
|
| MD5 |
f8e61cd4e741aba9a8cf089170a2eb7d
|
|
| BLAKE2b-256 |
a12e40f95d60326cb3338c10142879cb0036a5267efc88323f5464017b3281de
|
Provenance
The following attestation bundles were made for k_hhc-1.0.6.tar.gz:
Publisher:
release.yml on kirbyevanj/k-hhc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
k_hhc-1.0.6.tar.gz -
Subject digest:
549648af0fcc23826e25a99ae129085e82fa54ead25def11f79d4da76952526a - Sigstore transparency entry: 695339817
- Sigstore integration time:
-
Permalink:
kirbyevanj/k-hhc@7b1dd7017894733ded5b861e006bdb580f38906b -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/kirbyevanj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7b1dd7017894733ded5b861e006bdb580f38906b -
Trigger Event:
push
-
Statement type:
File details
Details for the file k_hhc-1.0.6-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: k_hhc-1.0.6-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 76.8 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33b5b44224cf10ee00b812430b02dd193d63d3bcc5180560aa11d9e3a5df2455
|
|
| MD5 |
468c6f2d286141679b27c96446b13585
|
|
| BLAKE2b-256 |
faf47c1f0f28e01fb1f247685df3f36eb7e86de092a25c0dad8804aed26a5999
|
Provenance
The following attestation bundles were made for k_hhc-1.0.6-cp312-cp312-win_amd64.whl:
Publisher:
release.yml on kirbyevanj/k-hhc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
k_hhc-1.0.6-cp312-cp312-win_amd64.whl -
Subject digest:
33b5b44224cf10ee00b812430b02dd193d63d3bcc5180560aa11d9e3a5df2455 - Sigstore transparency entry: 695339835
- Sigstore integration time:
-
Permalink:
kirbyevanj/k-hhc@7b1dd7017894733ded5b861e006bdb580f38906b -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/kirbyevanj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7b1dd7017894733ded5b861e006bdb580f38906b -
Trigger Event:
push
-
Statement type:
File details
Details for the file k_hhc-1.0.6-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: k_hhc-1.0.6-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 99.9 kB
- Tags: CPython 3.12, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8baf819cb48ba12e4603f2829844601513a3adf0d6e002b585aad58807a5fbf3
|
|
| MD5 |
3db0bfd9ae2c5377317fd3079f178236
|
|
| BLAKE2b-256 |
ae67d2925be7e6853af434478beac3682da19f02175876f50fb8b1556d57d81e
|
Provenance
The following attestation bundles were made for k_hhc-1.0.6-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
release.yml on kirbyevanj/k-hhc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
k_hhc-1.0.6-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
8baf819cb48ba12e4603f2829844601513a3adf0d6e002b585aad58807a5fbf3 - Sigstore transparency entry: 695339827
- Sigstore integration time:
-
Permalink:
kirbyevanj/k-hhc@7b1dd7017894733ded5b861e006bdb580f38906b -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/kirbyevanj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7b1dd7017894733ded5b861e006bdb580f38906b -
Trigger Event:
push
-
Statement type:
File details
Details for the file k_hhc-1.0.6-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: k_hhc-1.0.6-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 79.9 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e6007dd54369673847023c4c8b98a9cb87b5467f6d49adc72e1d6721ce9df5f
|
|
| MD5 |
3587644956ac3fb1ca45b9f4afd2948e
|
|
| BLAKE2b-256 |
3e4f308286f08af2b030ad88af481dfe1600fdad6f74af13784e1fc4bc087799
|
Provenance
The following attestation bundles were made for k_hhc-1.0.6-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
release.yml on kirbyevanj/k-hhc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
k_hhc-1.0.6-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
7e6007dd54369673847023c4c8b98a9cb87b5467f6d49adc72e1d6721ce9df5f - Sigstore transparency entry: 695339821
- Sigstore integration time:
-
Permalink:
kirbyevanj/k-hhc@7b1dd7017894733ded5b861e006bdb580f38906b -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/kirbyevanj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7b1dd7017894733ded5b861e006bdb580f38906b -
Trigger Event:
push
-
Statement type:
File details
Details for the file k_hhc-1.0.6-cp312-cp312-macosx_10_9_x86_64.whl.
File metadata
- Download URL: k_hhc-1.0.6-cp312-cp312-macosx_10_9_x86_64.whl
- Upload date:
- Size: 82.6 kB
- Tags: CPython 3.12, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ecff9baac990241dcade8780b91a8815ffa31c41f9cf9d5e67ffa9fa0ce7eef
|
|
| MD5 |
7185697fcdf65cdf8578623f91ca9986
|
|
| BLAKE2b-256 |
765ac0a51d4b9ee1a27a891ebf26fbb1aa2cd413c40a855c82393aee73ce34e2
|
Provenance
The following attestation bundles were made for k_hhc-1.0.6-cp312-cp312-macosx_10_9_x86_64.whl:
Publisher:
release.yml on kirbyevanj/k-hhc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
k_hhc-1.0.6-cp312-cp312-macosx_10_9_x86_64.whl -
Subject digest:
8ecff9baac990241dcade8780b91a8815ffa31c41f9cf9d5e67ffa9fa0ce7eef - Sigstore transparency entry: 695339819
- Sigstore integration time:
-
Permalink:
kirbyevanj/k-hhc@7b1dd7017894733ded5b861e006bdb580f38906b -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/kirbyevanj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7b1dd7017894733ded5b861e006bdb580f38906b -
Trigger Event:
push
-
Statement type:
File details
Details for the file k_hhc-1.0.6-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: k_hhc-1.0.6-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 76.2 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
826584eb083b79bfd72a3caac52842d0beee222069b5fac50d00f14ed6f75cb6
|
|
| MD5 |
b6bdd6d898d176b682ca51025c681233
|
|
| BLAKE2b-256 |
ca188bfa2870737b3d564d5c2aa3ef5392885e2ae0707b53c6be00b2a8192ff5
|
Provenance
The following attestation bundles were made for k_hhc-1.0.6-cp311-cp311-win_amd64.whl:
Publisher:
release.yml on kirbyevanj/k-hhc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
k_hhc-1.0.6-cp311-cp311-win_amd64.whl -
Subject digest:
826584eb083b79bfd72a3caac52842d0beee222069b5fac50d00f14ed6f75cb6 - Sigstore transparency entry: 695339823
- Sigstore integration time:
-
Permalink:
kirbyevanj/k-hhc@7b1dd7017894733ded5b861e006bdb580f38906b -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/kirbyevanj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7b1dd7017894733ded5b861e006bdb580f38906b -
Trigger Event:
push
-
Statement type:
File details
Details for the file k_hhc-1.0.6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: k_hhc-1.0.6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 98.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad87262e20174a571f42b3c8ec80d8ddd1529fe65ea59d83451a319ab92550b7
|
|
| MD5 |
d1c0a2db95ed2e4d28b48044598fe343
|
|
| BLAKE2b-256 |
15bc387fdc70a5ac131e9cd5c94bbe8a44b7851923d6aaf1598c0a91da45c83b
|
Provenance
The following attestation bundles were made for k_hhc-1.0.6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
release.yml on kirbyevanj/k-hhc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
k_hhc-1.0.6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
ad87262e20174a571f42b3c8ec80d8ddd1529fe65ea59d83451a319ab92550b7 - Sigstore transparency entry: 695339825
- Sigstore integration time:
-
Permalink:
kirbyevanj/k-hhc@7b1dd7017894733ded5b861e006bdb580f38906b -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/kirbyevanj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7b1dd7017894733ded5b861e006bdb580f38906b -
Trigger Event:
push
-
Statement type:
File details
Details for the file k_hhc-1.0.6-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: k_hhc-1.0.6-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 78.6 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76b8c6abe0ec1e62dfc3f6b0139329866342850546841ad27cae00d1cea04484
|
|
| MD5 |
6ecd40dd70f87779a3e4e12d952baf02
|
|
| BLAKE2b-256 |
310ed9719abf7f9e7804037b5ccf270d8dbcac2c5795c0eb973f7c1ecbf2f2e1
|
Provenance
The following attestation bundles were made for k_hhc-1.0.6-cp311-cp311-macosx_11_0_arm64.whl:
Publisher:
release.yml on kirbyevanj/k-hhc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
k_hhc-1.0.6-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
76b8c6abe0ec1e62dfc3f6b0139329866342850546841ad27cae00d1cea04484 - Sigstore transparency entry: 695339829
- Sigstore integration time:
-
Permalink:
kirbyevanj/k-hhc@7b1dd7017894733ded5b861e006bdb580f38906b -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/kirbyevanj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7b1dd7017894733ded5b861e006bdb580f38906b -
Trigger Event:
push
-
Statement type:
File details
Details for the file k_hhc-1.0.6-cp311-cp311-macosx_10_9_x86_64.whl.
File metadata
- Download URL: k_hhc-1.0.6-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 81.2 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c9d96c294d88dcef8f3e6a74c07c603c24a0573ca9f9a51452fd129091817ac
|
|
| MD5 |
3d591dfc8dc48bc9f78ede2e707d7ea0
|
|
| BLAKE2b-256 |
81e00d39870630c42b026b1984797bb1f024c1474ae65bef4f69707e314133cd
|
Provenance
The following attestation bundles were made for k_hhc-1.0.6-cp311-cp311-macosx_10_9_x86_64.whl:
Publisher:
release.yml on kirbyevanj/k-hhc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
k_hhc-1.0.6-cp311-cp311-macosx_10_9_x86_64.whl -
Subject digest:
8c9d96c294d88dcef8f3e6a74c07c603c24a0573ca9f9a51452fd129091817ac - Sigstore transparency entry: 695339820
- Sigstore integration time:
-
Permalink:
kirbyevanj/k-hhc@7b1dd7017894733ded5b861e006bdb580f38906b -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/kirbyevanj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7b1dd7017894733ded5b861e006bdb580f38906b -
Trigger Event:
push
-
Statement type: