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.

Parameters:

key – keyword to use

Returns:

dictionary cipher map

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

Deciphers a message given a cipher map

Parameters:
  • message – Message to decipher

  • cipher_map – Dictionary mapping to use

Returns:

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.

Parameters:
  • message – Message to encipher

  • cipher_map – Cipher map

Returns:

enciphered string

>>> encipher('Hello World!!', create_cipher_map('Goodbye!!'))
'CYJJM VMQJB!!'
ciphers.simple_keyword_cypher.main() None

Handles I/O

Returns:

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'