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.1.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.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: base62_py-1.4.1.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.1.tar.gz
Algorithm Hash digest
SHA256 2093f304c21178aa11fe932cc136ae38fa3af18a30e59f5aa988b35a8fc58c8e
MD5 e218f17b0d54b64a20bde820e0037ab9
BLAKE2b-256 a7beb2f84f15eb523b36fd68287e9fa1da05fbfdd7c89fed03223b8cbe00194d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: base62_py-1.4.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d09d3b2ffe9c513753fea74943bbfebb0bf93a0007f90c443fe204277dca583c
MD5 d410154c323b44a47eb5193260567fdc
BLAKE2b-256 a313ba26bdf4091ea829ec584a22e4eebf201fb16efd148b00d7a6b8b6658b97

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.4.1 This release

2 files

1.4.0

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