9 "from support.utilities import *\n",
10 "from support.language_models import *\n",
11 "from support.norms import *\n",
12 "from cipher.keyword_cipher import *"
21 "def keyword_encipher_p(message, keyword, wrap_alphabet=KeywordWrapAlphabet.from_a):\n",
22 " cipher_alphabet = keyword_cipher_alphabet_of(keyword, wrap_alphabet)\n",
23 " cipher_translation = {p: c for p, c in zip(string.ascii_lowercase, cipher_alphabet)}\n",
24 " return cat(keyword_encipher_letter(letter, cipher_translation) for letter in message)"
33 "def keyword_decipher_p(message, keyword, wrap_alphabet=KeywordWrapAlphabet.from_a):\n",
34 " cipher_alphabet = keyword_cipher_alphabet_of(keyword, wrap_alphabet)\n",
35 " plaintext_translation = {c: p for p, c in zip(string.ascii_lowercase, cipher_alphabet)}\n",
36 " return cat(keyword_encipher_letter(letter, plaintext_translation) for letter in message)"
45 "def keyword_encipher_letter(letter, cipher_translation):\n",
46 " if letter in cipher_translation:\n",
47 " return cipher_translation[letter]\n",
65 "output_type": "execute_result"
69 "keyword_encipher('test message', 'keyword')"
85 "output_type": "execute_result"
89 "keyword_encipher_p('test message', 'keyword')"
94 "execution_count": 10,
103 "execution_count": 10,
105 "output_type": "execute_result"
109 "keyword_decipher_p('qopq hoppkdo', 'keyword')"
114 "execution_count": null,
122 "display_name": "Python 3",
123 "language": "python",
131 "file_extension": ".py",
132 "mimetype": "text/x-python",
134 "nbconvert_exporter": "python",
135 "pygments_lexer": "ipython3",