Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Base62 encode/decode

base62.py

Run the Python Base62 test next to the implementation for concrete examples.

This module converts non-negative integers into compact Base62 strings and reverses the operation, all with zero external dependencies. The alphabet is the conventional 0-9A-Za-z ordering, which yields shorter representations than Base10 for the same value while remaining URL-safe and case-sensitive.

Encoding proceeds by repeated division: each remainder maps to a character, and the process terminates when the quotient reaches zero. Decoding inverts this by accumulating each character's positional value. Both paths are deterministic and total over the domain of non-negative integers, so any value you encode will decode back to the original integer exactly.

The implementation relies solely on the Python standard library; there is no service, package, or runtime component to install. This keeps the utility portable across environments and trivially auditable, since the entire logic fits in a few functions with no hidden state. For verification, the accompanying test module exercises boundary values, round-trip fidelity, and the ordering of the alphabet, so you can confirm behavior without external fixtures.

About

Encode integers to short Base62 ids and back — dependency-free.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages