ciphers.simple_keyword_cypher

Functions

create_cipher_map(→ dict[str, str])

Returns a cipher map given a keyword.

decipher(→ str)

Deciphers a message given a cipher map

encipher(→ str)

Enciphers a message given a cipher map.

main(→ None)

Handles I/O

remove_duplicates(→ str)

Removes duplicate alphabetic characters in a keyword (letter is ignored after its

Module Contents

ciphers.simple_keyword_cypher.create_cipher_map(key: str) dict[str, str]

Returns a cipher map given a keyword. :param key: keyword to use :return: dictionary cipher map

ciphers.simple_keyword_cypher.decipher(message: str, cipher_map: dict[str, str]) str

Deciphers a message given a cipher map :param message: Message to decipher :param cipher_map: Dictionary mapping to use :return: Deciphered string >>> cipher_map = create_cipher_map(‘Goodbye!!’) >>> decipher(encipher(‘Hello World!!’, cipher_map), cipher_map) ‘HELLO WORLD!!’

ciphers.simple_keyword_cypher.encipher(message: str, cipher_map: dict[str, str]) str

Enciphers a message given a cipher map. :param message: Message to encipher :param cipher_map: Cipher map :return: enciphered string >>> encipher(‘Hello World!!’, create_cipher_map(‘Goodbye!!’)) ‘CYJJM VMQJB!!’

ciphers.simple_keyword_cypher.main() None

Handles I/O :return: void

ciphers.simple_keyword_cypher.remove_duplicates(key: str) str
Removes duplicate alphabetic characters in a keyword (letter is ignored after its

first appearance).

Parameters:

key – Keyword to use

Returns:

String with duplicates removed

>>> remove_duplicates('Hello World!!')
'Helo Wrd'