Skip to main content

Native codecs extension

Project description

PyPi Read The Docs Build Status Coverage Status Python Versions Requirements Status Known Vulnerabilities License

Codecs Extension

This library extends the native codecs library and provides some new encodings (static or parametrized, like rot-N or xor-N).

Codec Conversions Comment
ascii85 Ascii85 <-> text Python 3 only
base16 Base16 <-> text
base32 Base32 <-> text
base64 Base64 <-> text
base85 Base85 <-> text Python 3 only
base100 Base100 <-> text Python 3 only
dna-N DNA-N <-> text implements the 8 rules of DNA sequences (N belongs to [1,8])
leetspeak leetspeak <-> text based on minimalistic elite speaking rules
markdown markdown --> HTML unidirectional
morse morse <-> text uses whitespace as a separator
nokia3310 Nokia 3310 keystrokes <-> text uses "-" as a separator for encoding, "-" or "_" or whitespace for decoding
rot-N ROT(N) <-> text aka Caesar cipher (N belongs to [1,25])
xor-N XOR(N) <-> text XOR with a single byte (N belongs to [1,255])

Setup

This library is available on PyPi and can be simply installed using Pip:

pip install codext

or

pip3 install codext

Usage

Example with Base100 (emoji's):

>>> codecs.encode("this is a test", "base100")
'👫👟👠👪🐗👠👪🐗👘🐗👫👜👪👫'
>>> codecs.decode("👫👟👠👪🐗👠👪🐗👘🐗👫👜👪👫", "base100")
'this is a test'

Example with DNA sequence encoding:

>>> 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'

Example with morse:

>>> 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'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codext-1.0.3.tar.gz (21.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page