Skip to main content

base62-py

Custom Base-62 Encoder

GitHub tag (latest by date) GitHub last commit GitHub issues PyPI - Version

This repository contains the version of my encoder/decoder for Base-62 in three languages:

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

base62_py-1.4.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

base62_py-1.4.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file base62_py-1.4.0.tar.gz.

File metadata

  • Download URL: base62_py-1.4.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.2

File hashes

Hashes for base62_py-1.4.0.tar.gz
Algorithm Hash digest
SHA256 44555ae7fbab61cb05d5fe561b933d9eb9ca208cffd93915de023b7f277f8e68
MD5 b665138e205c5759386e2a2dfaa2e37a
BLAKE2b-256 13999ed263a67398d3001ba7f9cb1870c7a9ac11a834534620fc9ee9e664da39

See more details on using hashes here.

File details

Details for the file base62_py-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: base62_py-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.2

File hashes

Hashes for base62_py-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22e96b3a0e0f77e0aca451f470dccff726fa5e7f6024d66072793334f0ae5085
MD5 a49906e959dba422c16bb93f9f3289b1
BLAKE2b-256 62cad9be93142161f5b4e870220923c9f24a8b1c933e60bde76c0a792a603f1a

See more details on using hashes here.

Release history Release notifications | RSS feed

1.4.1

2 files

This release

1.4.0 This release

2 files

1.3.16

2 files

1.3.15

2 files

1.3.14

2 files

1.3.13

2 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