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!') '.... . .-.. .-.. --- --..-- / .-- --- .-. .-.. -.. -.-.--'
Image Substitution¶
- class
crypyto.substitution_alphabets.
ImageSubstitution
(abc, directory, extension)[source]¶ImageSubstitution is a base class which is used by all the image-based alphabets
Parameters:
- abc (str) – The plain text alphabet this image-based alphabet have a translation to
- directory (str) – The directory where the image files are located (inside this package ->
/static/directory/
)- extension (str) – The file extension the image files use
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 specified substitution 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
Templar Cipher¶
Templar represents an
ImageSubstitution
object adjusted to the Templar CipherExamples:
>>> from crypyto.substitution_alphabets import Templar >>> Templar.encrypt('Hello, world!', 'templar_hello.png') >>> Templar.encrypt('Hello, world!', 'templar_hello_max.png', 5)templar_hello.png:
templar_hello_max.png: