base62-py
Custom Base-62 Encoder
This repository contains the version of my encoder/decoder for Base-62 in three languages:
- Golang;
- Python;
- TypeScript.
Motivation
I needed an efficient way to apply a Base-62 encoding/decoding algorithm working the same way in TypeScript/Javascript, Golang and Python environments.
Usage
Both versions use the same following dictionary:
| Value | Character | Value | Character | Value | Character | Value | Character | Value | Character |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 |
13 | d |
26 | q |
39 | D |
52 | Q |
| 1 | 1 |
14 | e |
27 | r |
40 | E |
53 | R |
| 2 | 2 |
15 | f |
28 | s |
41 | F |
54 | S |
| 3 | 3 |
16 | g |
29 | t |
42 | G |
55 | T |
| 4 | 4 |
17 | h |
30 | u |
43 | H |
56 | U |
| 5 | 5 |
18 | i |
31 | v |
44 | I |
57 | V |
| 6 | 6 |
19 | j |
32 | w |
45 | J |
58 | W |
| 7 | 7 |
20 | k |
33 | x |
46 | K |
59 | X |
| 8 | 8 |
21 | l |
34 | y |
47 | L |
60 | Y |
| 9 | 9 |
22 | m |
35 | z |
48 | M |
61 | Z |
| 10 | a |
23 | n |
36 | A |
49 | N |
||
| 11 | b |
24 | o |
37 | B |
50 | O |
||
| 12 | c |
25 | p |
38 | C |
51 | P |
In other words, they use the following base: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.
pip install base62-py
from base62 import decode, encode, is_valid_base62
value = 18969
encoded = encode(value)
# 4VX
print(encoded)
decoded = decode(encoded)
assert value == decoded
assert is_valid_base62(encoded)
Tests
$ pip install -e . && python3 -m unittest discover
License
Both versions are available under a MIT license (see LICENSE).
© 2021-2026 Cyril Dever. All rights reserved.
Metadata
Release files for base62-py 1.4.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 |
|---|---|---|---|---|
| base62_py-1.4.2.tar.gz | 4.7 kB | Without provenance | Details for base62_py-1.4.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| base62_py-1.4.2-py3-none-any.whl | Python 3 | none | any | Details for base62_py-1.4.2-py3-none-any.whl |
Total release size: 10.6 kB
Release files / base62_py-1.4.2.tar.gz
| Download URL | base62_py-1.4.2.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a51c365c929cebbb4245bb1bcddf6376a113acd90f24da2ca5a086b9bad8e411
|
|
BLAKE2b-256 checksum How to use checksums |
cfec1d83276fce62591bad9c6445c6abfd729efb92fa8cead4b3f2a483e7ae37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.10.2
|
Release files / base62_py-1.4.2-py3-none-any.whl
| Download URL | base62_py-1.4.2-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3abf69ae0c11920ce51a9655d0f85b937272b0279f1311b6325b58616057e955
|
|
BLAKE2b-256 checksum How to use checksums |
84456a07ae83cbf91b28b6e6ba4f967f76ef9c24d02a03d25853335a082102ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.10.2
|
Security for base62-py 1.4.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.