Sign in
Log inSign up

Encoding/Decoding with Python

Alex's photo
Alex
·Jul 22, 2020·

1 min read

These last few years, I had fun with some challenges related to weird encodings (e.g. Morse, and so forth). So I decided to make something using Python to handle these particular ones. First, I discovered how the native codecs library worked in order to understand how to add my own codecs upon.

It then ended into a new package called CODecs EXTension enhancing the native one, available here. codext handles a myriad of new codecs and provides a CLI tool that is especially useful for chaining encodings.

Demonstration :

$ echo -en "Test string" | codext reverse
gnirts tseT

$ echo -en "Test string" | codext reverse swapcase
GNIRTS TSEt

$ echo -en "Test string" | codext reverse swapcase base58-bitcoin
JgZRLASSXJV4PaB

$ echo -en "Test string" | codext reverse swapcase base58-bitcoin barbie-2
<dFEURTT2<X5KtC

$ echo -en "Test string" | codext reverse swapcase base58-bitcoin barbie-2 html-entity
&lt;dFEURTT2&lt;X5KtC

$ echo -en "Test string" | codext reverse swapcase base58-bitcoin barbie-2 html-entity morse
.-... .-.. - -.-.-. -.. ..-. . ..- .-. - - ..--- .-... .-.. - -.-.-. -..- ..... -.- - -.-.

Documentation is also provided here for making new ones. A word to the wise... :-)