BaseN
Custom encoder that encodes any binary data to given alphabet.
Requirements
Python 3.8 and above. No additional dependencies.
Installation
pip install basen-encoder
Usage
Numbers
Encode a number to the string and back
import string
import basen
ALPHABET = string.ascii_letters + string.digits
for i in range(1000, 2000, 9):
encoded = basen.int2base(i, ALPHABET)
decoded = basen.base2int(encoded, ALPHABET)
print(i, encoded, decoded)
Output:
1000 qi 1000
1009 qr 1009
1018 qA 1018
1027 qJ 1027
...
Huge numbers
Even huge numbers can be encoded as well.
import string
import basen
ALPHABET = string.ascii_letters + string.digits
NUM = 10**100
encoded = basen.int2base(i, ALPHABET)
decoded = basen.base2int(encoded, ALPHABET)
print(NUM)
print(encoded)
print(decoded)
Output:
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Am851IcwtXApqVErDmkjfH9ikry1v4YsyaP4zUrrmM8H8j83wfxbV02K
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Encode a binary
Encode a binary data to printable text like base64 but with an arbitrary alphabet.
import string
import basen
ALPHABET = string.ascii_letters
DATA = "Some binary data..."
encoder = basen.BaseN(string.ascii_letters, 3)
encoded = encoder.encode(DATA)
decoded = encoder.decode(encoded)
print(DATA)
print(encoded)
print(decoded)
Output:
Some binary data...
aMUkfaVgYAaXhpLbbsxuaUOUCaTprkavVgx==
bytearray(b'Some binary data...')
Metadata
Release files for basen-encoder 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| basen_encoder-1.0.2.tar.gz | 103.8 kB | Without provenance | Details for basen_encoder-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| basen_encoder-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for basen_encoder-1.0.2-py3-none-any.whl |
Total release size: 109.4 kB
Release files / basen_encoder-1.0.2.tar.gz
| Download URL | basen_encoder-1.0.2.tar.gz |
|---|---|
| Size | 103.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e44f5b50aa134ea5136314def9da85b52c06c6bcdcc9a4a916a7e7d991e6003
|
|
BLAKE2b-256 checksum How to use checksums |
b0053e78bed3d03f8ea7313a7e0515bf00a096dca841a41ccc1eb358785eea63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.12.4 CPython/3.12.2
|
Release files / basen_encoder-1.0.2-py3-none-any.whl
| Download URL | basen_encoder-1.0.2-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76c57def490bae3da454b6ca16b83d41bd10cfe63f0d871119ef539337e17399
|
|
BLAKE2b-256 checksum How to use checksums |
b8aec4dfc9a07bcfe540e397602dd669d82e0d7ad3d597edf0e7815a52361ebb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.12.4 CPython/3.12.2
|
Security for basen-encoder 1.0.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.