Substitution Alphabets

This module provides simple usage of functions related to substitutions alphabets

Alphabets crypyto supports:

Morse Code

class crypyto.substitution_alphabets.Morse(word_splitter='/')[source]

Morse represents a Morse Code manipulator

Parameters:word_splitter (str) – A string which will be used to indicate words separation. Defaults to '/'
decrypt(cipher)[source]

Returns translated cipher into plain text

Parameters:cipher (str) – The morse code to be translated into plain text

Examples

>>> from crypyto.substitution_alphabets import Morse
>>> morse = Morse()
>>> morse.decrypt('.... . .-.. .-.. --- --..-- / .-- --- .-. .-.. -.. -.-.--')
'HELLO, WORLD!'
encrypt(text)[source]

Returns translated text into Morse Code (str)

Parameters:text (str) – The text to be translated into Morse Code

Examples

>>> from crypyto.subsititution_alphabets import Morse
>>> morse = Morse()
>>> morse.encrypt('Hello, world!')
'.... . .-.. .-.. --- --..-- / .-- --- .-. .-.. -.. -.-.--'

Binary Translation

class crypyto.substitution_alphabets.Binary(letter_splitter=' ')[source]

Binary represents a text-to-binary manipulator

Parameters:letter_splitter (str) – A string which will be used to indicate characters separation. Defaults to ' '
decrypt(cipher)[source]

Returns the binary-cipher translated to text

Parameters:cipher (str) – The binary-cipher to be translated to normal text

Examples

>>> from crypyto.substitution_alphabets import Binary
>>> b = Binary()
>>> b.decrypt('1001000 1100101 1101100 1101100 1101111 101100 100000 1110111 1101111 1110010 1101100 1100100 100001')
'Hello, world!'
encrypt(text)[source]

Returns the text translated to binary

Parameters:text (str) – The text to be translated to binary

Examples

>>> from crypyto.substitution_alphabets import Binary
>>> b = Binary()
>>> b.encrypt('Hello, world!')
'1001000 1100101 1101100 1101100 1101111 101100 100000 1110111 1101111 1110010 1101100 1100100 100001'

Pigpen Cipher

class crypyto.substitution_alphabets.Pigpen[source]

Pigpen represents a Pigpen Cipher manipulator

decrypt(filename)[source]

Returns the image cipher translated to normal text (str). It will most often do it wrong, because of specifications on Pigpen. I’ll try to fix that soon.

Parameters:filename (str) – Filename of the cipher image file
Raise:
ValueError: If the size of the respective image doensn’t match the cipher pattern. I’ll try to work on that.

Examples

>>> from crypyto.substitution_alphabets import Pigpen
>>> pigpgen = Pigpen()
>>> pigpen.decrypt('pigpen_hello.png')
'BEJJMWMJJD'
>>> pigpen.decrypt('pigpen_hello_max.png')
'BEJJMWMJJD'
encrypt(text, filename='output.png', max_in_line=30)[source]

Creates an image file with the translated text

Parameters:
  • text (str) – Text to be translated to the Pigpen alphabet
  • filename (str) – The filename of the image file with the translated text. Defaults to 'output.png'
  • max_in_line (int) – The max number of letters per line. Defaults to 30

Examples

>>> from crypyto.substitution_alphabets import Pigpen
>>> pigpen = Pigpen()
>>> pigpen.encrypt('Hello, world!', 'pigpen_hello.png')
>>> pigpen.encrypt('Hello, world!', 'pigpen_hello_max.png', 5)

pigpen_hello.png:

Encrypted hello world

Encrypted hello world

pigpen_hello_max.png:

Encrypted hello world (5 letters per line)

Encrypted hello world (5 letters per line)

Templar Cipher

class crypyto.substitution_alphabets.Templar[source]

Templar represents a Templar Cipher manipulator

decrypt(filename)[source]

Returns the image cipher translated to normal text (str)

Parameters:filename (str) – Filename of the cipher image file
Raise:
ValueError: If the size of the respective image doensn’t match the cipher pattern. I’ll try to work on that.

Examples

>>> from crypyto.substitution_alphabets import Templar
>>> templar = Templar()
>>> templar.decrypt('templar_hello.png')
'HELLOWORLD'
>>> templar.decrypt('templar_hello_max.png')
'HELLOWORLD'
encrypt(text, filename='output.png', max_in_line=30)[source]

Creates an image file with the translated text

Parameters:
  • text (str) – Text to be translated to the Templar alphabet
  • filename (str) – The filename of the image file with the translated text. Defaults to 'output.png'
  • max_in_line (int) – The max number of letters per line. Defaults to 30

Examples

>>> from crypyto.substitution_alphabets import Templar
>>> templar = Templar()
>>> templar.encrypt('Hello, world!', 'templar_hello.png')
>>> templar.encrypt('Hello, world!', 'templar_hello_max.png', 5)

templar_hello.png:

Encrypted hello world

Encrypted hello world

templar_hello_max.png:

Encrypted hello world (5 letters per line)

Encrypted hello world (5 letters per line)

Betamaze Alphabet

class crypyto.substitution_alphabets.Betamaze(random_rotate=False)[source]

Betamaze represents a Betamaze Alphabet Manipulator

Parameters:random_rotate (bool) – Whether to randomly rotate each square letter (as it is possible with Betamaze). Defaults to False
decrypt(filename)[source]

Returns the image cipher translated to normal text (str)

Parameters:filename (str) – Filename of the cipher image file
Raise:
ValueError: If the size of the respective image doensn’t match the cipher pattern. I’ll try to work on that.

Examples

>>> from crypyto.substitution_alphabets import Betamaze
>>> betamaze = Betamaze()
>>> betamaze.decrypt('betamaze_hello.png')
'HELLO, WORLD'
>>> betamaze.decrypt('betamaze_hello_random.png')
'HELLO, WORLD'
encrypt(text, filename='output.png', max_in_line=10)[source]

Creates an image file with the translated text

Parameters:
  • text (str) – Text to be translated to the Betamaze alphabet
  • filename (str) – The filename of the image file with the translated text. Defaults to 'output.png'
  • max_in_line (int) – The max number of letters per line. Defaults to 10

Examples

>>> from crypyto.substitution_alphabets import Betamaze
>>> betamaze = Betamaze()
>>> betamaze.encrypt('Hello, world!', 'betamaze_hello.png', 5)
>>>
>>> betamaze_random = Betamaze(random_rotate=True)
>>> betamaze_random.encrypt('Hello, world!', 'betamaze_hello_random.png', 5)

betamaze_hello.png:

Encrypted hello world (5 letters per line)

Encrypted hello world (5 letters per line)

betamaze_hello_random.png:

Encrypted hello world (5 letters per line and with random rotation)

Encrypted hello world (5 letters per line and with random rotation)