CodExt 
Encode/decode anything.
This library extends the native codecs library (namely for adding new custom encodings and character mappings) and provides a myriad of new encodings (static or parametrized, like rot or xor), hence its named combining CODecs EXTension.
$ pip install codext
| Want to contribute a new codec ? | Want to contribute a new macro ? |
|---|---|
| Check the documentation first Then PR your new codec |
PR your updated version of macros.json |
๐
Demonstrations
๐ป
Usage (main CLI tool) 
$ codext -i test.txt encode dna-1
GTGAGCGGGTATGTGA
$ echo -en "test" | codext encode morse
- . ... -
$ echo -en "test" | codext encode braille
โ โ โ โ
$ echo -en "test" | codext encode base100
๐ซ๐๐ช๐ซ
Chaining codecs
$ echo -en "Test string" | codext encode reverse
gnirts tseT
$ echo -en "Test string" | codext encode reverse morse
--. -. .. .-. - ... / - ... . -
$ echo -en "Test string" | codext encode reverse morse dna-2
AGTCAGTCAGTGAGAAAGTCAGTGAGAAAGTGAGTGAGAAAGTGAGTCAGTGAGAAAGTCAGAAAGTGAGTGAGTGAGAAAGTTAGAAAGTCAGAAAGTGAGTGAGTGAGAAAGTGAGAAAGTC
$ echo -en "Test string" | codext encode reverse morse dna-2 octal
101107124103101107124103101107124107101107101101101107124103101107124107101107101101101107124107101107124107101107101101101107124107101107124103101107124107101107101101101107124103101107101101101107124107101107124107101107124107101107101101101107124124101107101101101107124103101107101101101107124107101107124107101107124107101107101101101107124107101107101101101107124103
$ echo -en "AGTCAGTCAGTGAGAAAGTCAGTGAGAAAGTGAGTGAGAAAGTGAGTCAGTGAGAAAGTCAGAAAGTGAGTGAGTGAGAAAGTTAGAAAGTCAGAAAGTGAGTGAGTGAGAAAGTGAGAAAGTC" | codext -d dna-2 morse reverse
test string
Using macros
$ codext add-macro my-encoding-chain gzip base63 lzma base64
$ codext list macros
example-macro, my-encoding-chain
$ echo -en "Test string" | codext encode my-encoding-chain
CQQFAF0AAIAAABuTgySPa7WaZC5Sunt6FS0ko71BdrYE8zHqg91qaqadZIR2LafUzpeYDBalvE///ug4AA==
$ codext remove-macro my-encoding-chain
$ codext list macros
example-macro
๐ป
Usage (base CLI tool) 
$ echo "Test string !" | base122
*.7!ft9๏ฟฝ-f9ร
$ echo "Test string !" | base91
"ONK;WDZM%Z%xE7L
$ echo "Test string !" | base91 | base85
B2P|BJ6A+nO(j|-cttl%
$ echo "Test string !" | base91 | base85 | base36 | base58-flickr
QVx5tvgjvCAkXaMSuKoQmCnjeCV1YyyR3WErUUErFf
$ echo "Test string !" | base91 | base85 | base36 | base58-flickr | base58-flickr -d | base36 -d | base85 -d | base91 -d
Test string !
$ echo "Test string !" | base91 | base85 | base36 | base58-flickr | debase -m 3
Test string !
$ echo "Test string !" | base91 | base85 | base36 | base58-flickr | debase -f Test
Test string !
๐ป
Usage (Python)
Getting the list of available codecs:
>>> 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 in range(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'
>>> with open("morse.txt", 'w', encoding="morse") as f:
f.write("this is a test")
14
>>> with open("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"))
***.**
. *
***.*
* .
.*
* .*
. *
** .*
***.**
** .**
.*
* .
* *. *
.*
* *.
* *. *
* .
* *.
* *. *
***.
*.*
***.*
* .*
๐
List of codecs
BaseXX
-
ascii85: classical ASCII85 (Python3 only) -
baseN: see base encodings (incl base32, 36, 45, 58, 62, 63, 64, 91, 100, 122) -
base-genericN: see base encodings ; supports any possible base
Binary
-
baudot: supports CCITT-1, CCITT-2, EU/FR, ITA1, ITA2, MTK-2 (Python3 only), UK, ... -
baudot-spaced: variant ofbaudot; groups of 5 bits are whitespace-separated -
baudot-tape: variant ofbaudot; outputs a string that looks like a perforated tape -
bcd: Binary Coded Decimal, encodes characters from their (zero-left-padded) ordinals -
bcd-extended0: variant ofbcd; encodes characters from their (zero-left-padded) ordinals using prefix bits0000 -
bcd-extended1: variant ofbcd; encodes characters from their (zero-left-padded) ordinals using prefix bits1111 -
excess3: uses Excess-3 (aka Stibitz code) binary encoding to convert characters from their ordinals -
gray: aka reflected binary code -
manchester: XORes each bit of the input with01 -
manchester-inverted: variant ofmanchester; XORes each bit of the input with10 -
rotateN: rotates characters by the specified number of bits (N belongs to [1, 7] ; Python 3 only)
Common
-
a1z26: keeps words whitespace-separated and uses a custom character separator -
cases: set of case-related encodings (including camel-, kebab-, lower-, pascal-, upper-, snake- and swap-case, slugify, capitalize, title) -
dummy: set of simple encodings (including reverse and word-reverse) -
octal: dummy octal conversion (converts to 3-digits groups) -
octal-spaced: variant ofoctal; dummy octal conversion, handling whitespace separators -
ordinal: dummy character ordinals conversion (converts to 3-digits groups) -
ordinal-spaced: variant ofordinal; dummy character ordinals conversion, handling whitespace separators
Compression
-
gzip: standard Gzip compression/decompression -
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
Cryptography
-
affine: aka Affine Cipher -
atbash: aka Atbash Cipher -
bacon: aka Baconian Cipher -
barbie-N: aka Barbie Typewriter (N belongs to [1, 4]) -
citrix: aka Citrix CTX1 passord encoding -
rotN: aka Caesar cipher (N belongs to [1,25]) -
scytaleN: encrypts using the number of letters on the rod (N belongs to [1,[) -
shiftN: shift ordinals (N belongs to [1,255]) -
xorN: XOR with a single byte (N belongs to [1,255])
Languages
-
braille: well-known braille language (Python 3 only) -
ipsum: aka lorem ipsum -
leetspeak: based on minimalistic elite speaking rules -
morse: uses whitespace as a separator -
navajo: only handles letters (not full words from the Navajo dictionary) -
radio: aka NATO or radio phonetic alphabet -
southpark: converts letters to Kenny's language from Southpark (whitespace is also handled) -
southpark-icase: case insensitive variant ofsouthpark -
tomtom: similar tomorse, using slashes and backslashes
Others
-
dna: implements the 8 rules of DNA sequences (N belongs to [1,8]) -
html: implements entities according to this reference -
letter-indices: encodes consonants and/or vowels with their corresponding indices -
markdown: unidirectional encoding from Markdown to HTML -
url: aka URL encoding
Steganography
-
klopf: aka Klopf code ; Polybius square with trivial alphabetical distribution -
resistor: aka resistor color codes -
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 ofwhitespace; 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")



