ciphers.simple_substitution_cipher

Attributes

LETTERS

Functions

check_valid_key(→ None)

Check if the key is valid (contains all 26 letters of the alphabet exactly once).

decrypt_message(→ str)

encrypt_message(→ str)

get_random_key(→ str)

Generate a random substitution cipher key.

main(→ None)

translate_message(→ str)

Module Contents

ciphers.simple_substitution_cipher.check_valid_key(key: str) → None

Check if the key is valid (contains all 26 letters of the alphabet exactly once). Exits the program if the key is invalid.

>>> check_valid_key('LFWOAYUISVKMNXPBDCRJTQEGHZ')
>>> check_valid_key('INVALIDKEY')
Traceback (most recent call last):
    ...
SystemExit: Error in the key or symbol set.
ciphers.simple_substitution_cipher.decrypt_message(key: str, message: str) → str
>>> decrypt_message('LFWOAYUISVKMNXPBDCRJTQEGHZ', 'Ilcrism Olcvs')
'Harshil Darji'
ciphers.simple_substitution_cipher.encrypt_message(key: str, message: str) → str
>>> encrypt_message('LFWOAYUISVKMNXPBDCRJTQEGHZ', 'Harshil Darji')
'Ilcrism Olcvs'
ciphers.simple_substitution_cipher.get_random_key() → str

Generate a random substitution cipher key.

>>> random.seed(0)
>>> get_random_key()
'OAXSGFHKWUECVDRLTJZPQIBNYM'
ciphers.simple_substitution_cipher.main() → None
ciphers.simple_substitution_cipher.translate_message(key: str, message: str, mode: str) → str
ciphers.simple_substitution_cipher.LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'