codext defines a far broader set of Base-encodings than in the original library.

Classical base 2^N encodings

This namely adds the classical BaseXX encodings like 16 (hexadecimal) and 32 (RFC 3548), which are not available in the native codecs.

Common base encodings with N a power of 2:

Codec Conversions Aliases Comment
base2 text <-> Base2 encoded text (base[-_]?2|bin)-inv(erted)?
base4 text <-> Base4 encoded text base[-_]?4-inv(erted) charset: 1234
base8 text <-> Base8 encoded text base[-_]?8-inv(erted) charset: abcdefgh
base16 text <-> Base16 encoded text base[-_]?16-inv(erted)
base32 text <-> Base32 encoded text base[-_]?32-inv(erted)
zbase32 text <-> ZBase32 encoded text z[-_]?base[-_]?32 human-oriented Base32
base64 text <-> Base64 encoded text base[-_]?64-inv(erted)


All the aliases are case insensitive for base encodings.

>>> codext.encode("test", "base2")
>>> codext.encode("test", "base2-inv")
>>> codecs.encode("this is a test", "base16")
>>> codecs.decode("7468697320697320612074657374", "base16")
'this is a test'
>>> codecs.encode("this is a test", "base16-inv")
>>> codext.encode("this is a test", "base32")
>>> codext.decode("ORUGS4ZANFZSAYJAORSXG5A=", "base32")
'this is a test'

Note that for base64, it overwrites the native base64_codec to also support en/decoding from str.

>>> codecs.encode("this is a test", "base64")
>>> codecs.decode("dGhpcyBpcyBhIHRlc3Q=", "base64")
'this is a test'

Generic base encodings

Codec Conversions Aliases Comment
base3 text <-> Base3 encoded text base[-_]?36(|[-_]inv(erted)?)
base36 text <-> Base36 encoded text base[-_]?36(|[-_]inv(erted)?)
base45 text <-> Base45 encoded text base[-_]?45(|[-_]inv(erted)?)
base58 text <-> Base58 encoded text base[-_]?58(|[-_](bc|bitcoin|rp|ripple|fl|flickr|short[-]?url|url)) supports Bitcoin, Ripple and short URL
base62 text <-> Base62 encoded text base[-_]?62(|[-_]inv(erted)?)
base63 text <-> Base63 encoded text base[-_]?63(|[-_]inv(erted)?)
base91 text <-> Base91 encoded text base[-_]?91(|[-_]inv(erted)?)
base91-alt text <-> Alternate Base91 encoded text base[-_]?91[-_]alt(?:ernate)?(|[-_]inv(erted)?) Another version of Base91
>>> codext.encode("test", "base3")
>>> codecs.encode("test", "base36")
>>> codecs.decode("4WMHTK6UZL044O91NKCEB8", "base36")
'this is a test'
>>> codext.encode("this is a test!", "base45")
>>> codext.decode('AWE+EDH44.OEOCC7WE QEX0', "base45")
'this is a test!'
>>> codext.encode("this is a test", "base58")
>>> codext.encode("this is a test", "base58-ripple")
>>> codext.encode("this is a test", "base58-url")
>>> codecs.encode("test", "base62")
>>> codecs.encode("this is a test", "base62")
>>> codecs.encode("This is a test !", "base91")
>>> codext.encode("This is a test !", "base91-alt")

Generic encodings

Base encodings are available for any N other than the ones explicitely specified using the "-generic" suffix. Their charsets consist of printable characters from the string module for N up to 100 and for characters composed from the 256 possible ordinals for a greater N.

>>> codext.encode("test", "base3-generic")
>>> codext.encode("test", "base17-generic")


This encoding relies on the base64 library and is only supported in Python 3.

Codec Conversions Aliases Comment
ascii85 text <-> ascii85 none Python 3 only
>>> codext.encode("this is a test", "ascii85")
>>> codext.decode("FD,B0+DGm>@3BZ'F*%", "ascii85")
'this is a test'
>>> with open("ascii85.txt", 'w', encoding="ascii85") as f:
    f.write("this is a test")
>>> with open("ascii85.txt", encoding="ascii85") as f:
'this is a test'

Other base encodings

Codec Conversions Aliases Comment
base85 text <-> Base85 encoded text base[-_]?85 Python 3 only (relies on base64 module)
base100 text <-> Base100 encoded text base[-_]?100|emoji Python 3 only
base122 text <-> Base122 encoded text base[-_]?122 Python 3 only
>>> codecs.encode("this is a test", "base85")
>>> codecs.decode("bZBXFAZc?TVIXv6b94", "base85")
'this is a test'
>>> codecs.encode("this is a test", "base100")
'šŸ‘«šŸ‘ŸšŸ‘ šŸ‘ŖšŸ—šŸ‘ šŸ‘ŖšŸ—šŸ‘˜šŸ—šŸ‘«šŸ‘œšŸ‘ŖšŸ‘«'
>>> codecs.decode("šŸ‘«šŸ‘ŸšŸ‘ šŸ‘ŖšŸ—šŸ‘ šŸ‘ŖšŸ—šŸ‘˜šŸ—šŸ‘«šŸ‘œšŸ‘ŖšŸ‘«", "base100")
'this is a test'
>>> codecs.encode("this is a test", "base122")
>>> codecs.decode(":\x1aŹ—\x19\x01Rs\x10\x18$\x07#\x15ft", "base122")
'this is a test'