CodExt is a (Python2-3 compatible) library that extends the native codecs library (namely for adding new custom encodings and character mappings) and provides 120+ new codecs, hence its name combining CODecs EXTension. It also features a guess mode for decoding multiple layers of encoding and CLI tools for convenience.
>>> import codext
>>> codext.list()
['ascii85', 'base85', 'base100', 'base122', ..., 'tomtom', 'dna', 'html', 'markdown', 'url', 'resistor', 'sms', 'whitespace', 'whitespace-after-before']
>>> codext.encode("this is a test", "base58-bitcoin")
'jo91waLQA1NNeBmZKUF'>>> codext.encode("this is a test", "base58-ripple")
'jo9rA2LQwr44eBmZK7E'>>> codext.encode("this is a test", "base58-url")
'JN91Wzkpa1nnDbLyjtf'>>> codecs.encode("this is a test", "base100")
'👫👟👠👪🐗👠👪🐗👘🐗👫👜👪👫'>>> codecs.decode("👫👟👠👪🐗👠👪🐗👘🐗👫👜👪👫", "base100")
'this is a test'>>> for i inrange(8):
print(codext.encode("this is a test", "dna-%d" % (i + 1)))
GTGAGCCAGCCGGTATACAAGCCGGTATACAAGCAGACAAGTGAGCGGGTATGTGA
CTCACGGACGGCCTATAGAACGGCCTATAGAACGACAGAACTCACGCCCTATCTCA
ACAGATTGATTAACGCGTGGATTAACGCGTGGATGAGTGGACAGATAAACGCACAG
AGACATTCATTAAGCGCTCCATTAAGCGCTCCATCACTCCAGACATAAAGCGAGAC
TCTGTAAGTAATTCGCGAGGTAATTCGCGAGGTAGTGAGGTCTGTATTTCGCTCTG
TGTCTAACTAATTGCGCACCTAATTGCGCACCTACTCACCTGTCTATTTGCGTGTC
GAGTGCCTGCCGGATATCTTGCCGGATATCTTGCTGTCTTGAGTGCGGGATAGAGT
CACTCGGTCGGCCATATGTTCGGCCATATGTTCGTCTGTTCACTCGCCCATACACT
>>> codext.decode("GTGAGCCAGCCGGTATACAAGCCGGTATACAAGCAGACAAGTGAGCGGGTATGTGA", "dna-1")
'this is a test'>>> codecs.encode("this is a test", "morse")
'- .... .. ... / .. ... / .- / - . ... -'>>> codecs.decode("- .... .. ... / .. ... / .- / - . ... -", "morse")
'this is a test'>>> withopen("morse.txt", 'w', encoding="morse") as f:
f.write("this is a test")
14>>> withopen("morse.txt",encoding="morse") as f:
f.read()
'this is a test'>>> codext.decode("""
=
X
:
x
n
r
y
Y
y
p
a
`
n
|
a
o
h
`
g
o
z """, "whitespace-after+before")
'CSC{not_so_invisible}'>>> print(codext.encode("An example test string", "baudot-tape"))
***.**
. *
***.*
* .
.*
* .*
. *
** .*
***.**
** .**
.*
* .
* *. *
.*
* *.
* *. *
* .
* *.
* *. *
***.
*.*
***.*
* .*
lz77: compresses the given data with the algorithm of Lempel and Ziv of 1977
lz78: compresses the given data with the algorithm of Lempel and Ziv of 1978
pkzip_deflate: standard Zip-deflate compression/decompression
pkzip_bzip2: standard BZip2 compression/decompression
pkzip_lzma: standard LZMA compression/decompression
:warning: Compression functions are of course definitely NOT encoding functions ; they are implemented for leveraging the .encode(...) API from codecs.
blake: includes BLAKE2b and BLAKE2s (Python 3 only ; relies on hashlib)
checksums: includes Adler32 and CRC32 (relies on zlib)
crypt: Unix's crypt hash for passwords (Python 3 and Unix only ; relies on crypt)
md: aka Message Digest ; includes MD4 and MD5 (relies on hashlib)
sha: aka Secure Hash Algorithms ; includes SHA1, 224, 256, 384, 512 (Python2/3) but also SHA3-224, -256, -384 and -512 (Python 3 only ; relies on hashlib)
shake: aka SHAKE hashing (Python 3 only ; relies on hashlib)
:warning: Hash functions are of course definitely NOT encoding functions ; they are implemented for convenience with the .encode(...) API from codecs and useful for chaning codecs.
hexagram: uses Base64 and encodes the result to a charset of I Ching hexagrams (as implemented here)
klopf: aka Klopf code ; Polybius square with trivial alphabetical distribution
resistor: aka resistor color codes
rick: aka Rick cipher (in reference to Rick Astley's song "Never gonna give you up")
sms: also called T9 code ; uses "-" as a separator for encoding, "-" or "_" or whitespace for decoding
whitespace: replaces bits with whitespaces and tabs
whitespace_after_before: variant of whitespace ; encodes characters as new characters with whitespaces before and after according to an equation described in the codec name (e.g. "whitespace+2*after-3*before")
We found that codext demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Malicious Go packages are impersonating popular libraries to install hidden loader malware on Linux and macOS, targeting developers with obfuscated payloads.
Bybit's $1.46B hack by North Korea's Lazarus Group pushes 2025 crypto losses to $1.6B in just two months, already surpassing all of 2024's $1.49B total.
OpenSSF has published OSPS Baseline, an initiative designed to establish a minimum set of security-related best practices for open source software projects.