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!!'
(message: str, cipher_map: dict[str, str])
| 44 | |
| 45 | |
| 46 | def encipher(message: str, cipher_map: dict[str, str]) -> str: |
| 47 | """ |
| 48 | Enciphers a message given a cipher map. |
| 49 | |
| 50 | :param message: Message to encipher |
| 51 | :param cipher_map: Cipher map |
| 52 | :return: enciphered string |
| 53 | |
| 54 | >>> encipher('Hello World!!', create_cipher_map('Goodbye!!')) |
| 55 | 'CYJJM VMQJB!!' |
| 56 | """ |
| 57 | return "".join(cipher_map.get(ch, ch) for ch in message.upper()) |
| 58 | |
| 59 | |
| 60 | def decipher(message: str, cipher_map: dict[str, str]) -> str: |