4 "cell_type": "markdown",
8 "Specification from [Codes and Ciphers](http://www.codesandciphers.org.uk/enigma/rotorspec.htm) page.\n",
10 "Example Enigma machines from [Louise Dale](http://enigma.louisedade.co.uk/enigma.html) (full simulation) and [EnigmaCo](http://enigmaco.de/enigma/enigma.html) (good animation of the wheels, but no ring settings).\n",
12 "There's also the nice Enigma simulator for Android by [Franklin Heath](https://franklinheath.co.uk/2012/02/04/our-first-app-published-enigma-simulator/), available on the [Google Play store](https://play.google.com/store/apps/details?id=uk.co.franklinheath.enigmasim&hl=en_GB)."
17 "execution_count": 333,
30 "execution_count": 334,
36 "wheel_i_spec = 'ekmflgdqvzntowyhxuspaibrcj'\n",
37 "wheel_ii_spec = 'ajdksiruxblhwtmcqgznpyfvoe'\n",
38 "wheel_iii_spec = 'bdfhjlcprtxvznyeiwgakmusqo'\n",
39 "wheel_iv_spec = 'esovpzjayquirhxlnftgkdcmwb'\n",
40 "wheel_v_spec = 'vzbrgityupsdnhlxawmjqofeck'\n",
41 "wheel_vi_spec = 'jpgvoumfyqbenhzrdkasxlictw'\n",
42 "wheel_vii_spec = 'nzjhgrcxmyswboufaivlpekqdt'\n",
43 "wheel_viii_spec = 'fkqhtlxocbjspdzramewniuygv'\n",
44 "beta_wheel_spec = 'leyjvcnixwpbqmdrtakzgfuhos'\n",
45 "gamma_wheel_spec = 'fsokanuerhmbtiycwlqpzxvgjd'\n",
47 "wheel_i_pegs = ['q']\n",
48 "wheel_ii_pegs = ['e']\n",
49 "wheel_iii_pegs = ['v']\n",
50 "wheel_iv_pegs = ['j']\n",
51 "wheel_v_pegs = ['z']\n",
52 "wheel_vi_pegs = ['z', 'm']\n",
53 "wheel_vii_pegs = ['z', 'm']\n",
54 "wheel_viii_pegs = ['z', 'm']\n",
56 "reflector_b_spec = '(ay) (br) (cu) (dh) (eq) (fs) (gl) (ip) (jx) (kn) (mo) (tz) (vw)'\n",
57 "reflector_c_spec = '(af) (bv) (cp) (dj) (ei) (go) (hy) (kr) (lz) (mx) (nw) (tq) (su)'"
62 "execution_count": 335,
68 "class LetterTransformer(object):\n",
69 " def __init__(self, specification, raw_transform=False):\n",
70 " if raw_transform:\n",
71 " transform = specification\n",
73 " transform = self.parse_specification(specification)\n",
74 " self.validate_transform(transform)\n",
75 " self.make_transform_map(transform)\n",
77 " def parse_specification(self, specification):\n",
78 " return specification\n",
80 " def validate_transform(self, transform):\n",
81 " \"\"\"A set of pairs, of from-to\"\"\"\n",
82 " if len(transform) != 26:\n",
83 " raise ValueError(\"Transform specification has {} pairs, requires 26\".\n",
84 " format(len(transform)))\n",
85 " for p in transform:\n",
87 " raise ValueError(\"Not all mappings in transform \"\n",
88 " \"have two elements\")\n",
89 " if len(set([p[0] for p in transform])) != 26:\n",
90 " raise ValueError(\"Transform specification must list 26 origin letters\") \n",
91 " if len(set([p[1] for p in transform])) != 26:\n",
92 " raise ValueError(\"Transform specification must list 26 destination letters\") \n",
94 " def make_empty_transform(self):\n",
95 " self.forward_map = [0] * 26\n",
96 " self.backward_map = [0] * 26\n",
98 " def make_transform_map(self, transform):\n",
99 " self.make_empty_transform()\n",
100 " for p in transform:\n",
101 " self.forward_map[ord(p[0]) - ord('a')] = ord(p[1]) - ord('a')\n",
102 " self.backward_map[ord(p[1]) - ord('a')] = ord(p[0]) - ord('a')\n",
103 " return self.forward_map, self.backward_map\n",
105 " def forward(self, letter):\n",
106 " if letter in string.ascii_lowercase:\n",
108 " (self.forward_map[(ord(letter) - ord('a')) % 26] + ord('a')))\n",
112 " def backward(self, letter):\n",
113 " if letter in string.ascii_lowercase:\n",
115 " (self.backward_map[(ord(letter) - ord('a')) % 26] + ord('a')))\n",
122 "execution_count": 336,
158 "execution_count": 336,
160 "output_type": "execute_result"
164 "tmap = [('z', 'a')] + [(l, string.ascii_lowercase[i+1]) for i, l in enumerate(string.ascii_lowercase[:-1])]\n",
170 "execution_count": 337,
233 "execution_count": 337,
235 "output_type": "execute_result"
239 "lt = LetterTransformer(tmap)\n",
240 "lt.forward_map, lt.backward_map"
245 "execution_count": 338,
253 "'bcdefghijklmnopqrstuvwxyza'"
256 "execution_count": 338,
258 "output_type": "execute_result"
262 "cat(lt.forward(l) for l in string.ascii_lowercase)"
267 "execution_count": 339,
275 "'zabcdefghijklmnopqrstuvwxy'"
278 "execution_count": 339,
280 "output_type": "execute_result"
284 "cat(lt.backward(l) for l in string.ascii_lowercase)"
289 "execution_count": 340,
295 "class Plugboard(LetterTransformer):\n",
296 " def parse_specification(self, specification):\n",
297 " return [tuple(p) for p in specification.split()]\n",
299 " def validate_transform(self, transform):\n",
300 " \"\"\"A set of pairs, of from-to\"\"\"\n",
301 " for p in transform:\n",
302 " if len(p) != 2:\n",
303 " raise ValueError(\"Not all mappings in transform\"\n",
304 " \"have two elements\")\n",
306 " def make_empty_transform(self):\n",
307 " self.forward_map = list(range(26))\n",
308 " self.backward_map = list(range(26))\n",
310 " def make_transform_map(self, transform):\n",
311 " expanded_transform = transform + [tuple(reversed(p)) for p in transform]\n",
312 " return super(Plugboard, self).make_transform_map(expanded_transform)"
317 "execution_count": 341,
323 "pb = Plugboard([('a', 'z'), ('b', 'y')], raw_transform=True)"
328 "execution_count": 342,
336 "'zycdefghijklmnopqrstuvwxba'"
339 "execution_count": 342,
341 "output_type": "execute_result"
345 "cat(pb.forward(l) for l in string.ascii_lowercase)"
350 "execution_count": 343,
358 "'zycdefghijklmnopqrstuvwxba'"
361 "execution_count": 343,
363 "output_type": "execute_result"
367 "cat(pb.backward(l) for l in string.ascii_lowercase)"
372 "execution_count": 344,
378 "pb = Plugboard('az by')"
383 "execution_count": 345,
391 "('zycdefghijklmnopqrstuvwxba', 'zycdefghijklmnopqrstuvwxba')"
394 "execution_count": 345,
396 "output_type": "execute_result"
400 "cat(pb.forward(l) for l in string.ascii_lowercase), cat(pb.backward(l) for l in string.ascii_lowercase)"
405 "execution_count": 346,
411 "class Reflector(Plugboard):\n",
412 " def parse_specification(self, specification):\n",
413 " return [tuple(p) for p in specification[1:-1].split(') (')]\n",
415 " def validate_transform(self, transform):\n",
416 " if len(transform) != 13:\n",
417 " raise ValueError(\"Reflector specification has {} pairs, requires 13\".\n",
418 " format(len(transform)))\n",
419 " if len(set([p[0] for p in transform] + \n",
420 " [p[1] for p in transform])) != 26:\n",
421 " raise ValueError(\"Reflector specification does not contain 26 letters\")\n",
423 " super(Reflector, self).validate_transform(transform)\n",
424 " except ValueError as v:\n",
425 " raise ValueError(\"Not all mappings in reflector have two elements\")"
430 "execution_count": 347,
453 "execution_count": 347,
455 "output_type": "execute_result"
459 "# reflector_b_text = '(AY) (BR) (CU) (DH) (EQ) (FS) (GL) (IP) (JX) (KN) (MO) (TZ) (VW)'\n",
460 "reflector_b_l = [tuple(p) for p in reflector_b_spec.lower()[1:-1].split(') (')]\n",
466 "execution_count": 348,
472 "reflector_b = Reflector(reflector_b_spec, raw_transform=False)"
477 "execution_count": 349,
485 "'yruhqsldpxngokmiebfzcwvjat'"
488 "execution_count": 349,
490 "output_type": "execute_result"
494 "cat(reflector_b.forward(l) for l in string.ascii_lowercase)"
499 "execution_count": 350,
505 "reflector_c = Reflector(reflector_c_spec)"
510 "execution_count": 351,
518 "'fvpjiaoyedrzxwgctkuqsbnmhl'"
521 "execution_count": 351,
523 "output_type": "execute_result"
527 "cat(reflector_c.forward(l) for l in string.ascii_lowercase)"
532 "execution_count": 352,
538 "class SimpleWheel(LetterTransformer):\n",
539 " def __init__(self, transform, position='a', raw_transform=False):\n",
540 " super(SimpleWheel, self).__init__(transform, raw_transform)\n",
541 " self.set_position(position)\n",
543 " def parse_specification(self, specification):\n",
544 " return list(zip(string.ascii_lowercase, specification))\n",
546 " def set_position(self, position):\n",
547 " self.position = ord(position) - ord('a')\n",
548 " self.position_l = position\n",
550 " def forward(self, letter):\n",
551 " if letter in string.ascii_lowercase:\n",
553 " (self.forward_map[(ord(letter) - ord('a') + self.position) % 26] - \n",
554 " self.position) % 26 + \n",
559 " def backward(self, letter):\n",
560 " if letter in string.ascii_lowercase:\n",
562 " (self.backward_map[(ord(letter) - ord('a') + self.position) % 26] - \n",
563 " self.position) % 26 + \n",
568 " def advance(self):\n",
569 " self.position = (self.position + 1) % 26\n",
570 " self.position_l = chr(self.position + ord('a'))\n",
571 " return self.position"
576 "execution_count": 353,
613 "execution_count": 353,
615 "output_type": "execute_result"
619 "rotor_1_transform = list(zip(string.ascii_lowercase, 'EKMFLGDQVZNTOWYHXUSPAIBRCJ'.lower()))\n",
625 "execution_count": 354,
631 "wheel_1 = SimpleWheel(rotor_1_transform, raw_transform=True)"
636 "execution_count": 355,
644 "('ekmflgdqvzntowyhxuspaibrcj', 'uwygadfpvzbeckmthxslrinqoj')"
647 "execution_count": 355,
649 "output_type": "execute_result"
653 "cat(wheel_1.forward(l) for l in string.ascii_lowercase), cat(wheel_1.backward(l) for l in string.ascii_lowercase)"
658 "execution_count": 356,
664 "wheel_2 = SimpleWheel(wheel_ii_spec)"
669 "execution_count": 357,
677 "('ajdksiruxblhwtmcqgznpyfvoe', 'ajpczwrlfbdkotyuqgenhxmivs')"
680 "execution_count": 357,
682 "output_type": "execute_result"
686 "cat(wheel_2.forward(l) for l in string.ascii_lowercase), cat(wheel_2.backward(l) for l in string.ascii_lowercase)"
691 "execution_count": 358,
699 "'cegikboqswuymxdhvfzjltrpna'"
702 "execution_count": 358,
704 "output_type": "execute_result"
708 "wheel_3 = SimpleWheel(wheel_iii_spec)\n",
709 "wheel_3.set_position('a')\n",
710 "wheel_3.advance()\n",
711 "cat(wheel_3.forward(l) for l in string.ascii_lowercase)"
716 "execution_count": 524,
722 "class Wheel(SimpleWheel):\n",
723 " def __init__(self, transform, ring_peg_letters, ring_setting=1, position='a', raw_transform=False):\n",
724 " self.ring_peg_letters = ring_peg_letters\n",
725 " self.ring_setting = ring_setting\n",
726 " super(Wheel, self).__init__(transform, position=position, raw_transform=raw_transform)\n",
727 " self.set_position(position)\n",
729 " def set_position(self, position):\n",
730 " super(Wheel, self).set_position(position)\n",
731 " self.peg_positions = [(ord(p) - ord(position)) % 26 for p in self.ring_peg_letters]\n",
732 " self.position = (self.position - self.ring_setting + 1) % 26\n",
734 " def advance(self):\n",
735 " super(Wheel, self).advance()\n",
736 " self.peg_positions = [(p - 1) % 26 for p in self.peg_positions]\n",
737 " return self.position"
742 "execution_count": 525,
748 "wheel_3 = Wheel(wheel_iii_spec, wheel_iii_pegs, position='b', ring_setting=1)"
753 "execution_count": 526,
764 "execution_count": 526,
766 "output_type": "execute_result"
770 "wheel_3.position, wheel_3.peg_positions"
775 "execution_count": 527,
786 "execution_count": 527,
788 "output_type": "execute_result"
792 "wheel_6 = Wheel(wheel_vi_spec, wheel_vi_pegs, position='b', ring_setting=3)\n",
793 "wheel_6.position, wheel_6.peg_positions"
798 "execution_count": 528,
806 "output_type": "stream",
839 "for _ in range(27):\n",
840 " wheel_6.advance()\n",
841 " print(wheel_6.position, wheel_6.peg_positions)"
846 "execution_count": 529,
852 "class Enigma(object):\n",
853 " def __init__(self, reflector_spec,\n",
854 " left_wheel_spec, left_wheel_pegs,\n",
855 " middle_wheel_spec, middle_wheel_pegs,\n",
856 " right_wheel_spec, right_wheel_pegs,\n",
857 " left_ring_setting, middle_ring_setting, right_ring_setting,\n",
858 " plugboard_setting):\n",
859 " self.reflector = Reflector(reflector_spec)\n",
860 " self.left_wheel = Wheel(left_wheel_spec, left_wheel_pegs, ring_setting=left_ring_setting)\n",
861 " self.middle_wheel = Wheel(middle_wheel_spec, middle_wheel_pegs, ring_setting=middle_ring_setting)\n",
862 " self.right_wheel = Wheel(right_wheel_spec, right_wheel_pegs, ring_setting=right_ring_setting)\n",
863 " self.plugboard = Plugboard(plugboard_setting)\n",
865 " def set_wheels(self, left_wheel_position, middle_wheel_position, right_wheel_position):\n",
866 " self.left_wheel.set_position(left_wheel_position)\n",
867 " self.middle_wheel.set_position(middle_wheel_position)\n",
868 " self.right_wheel.set_position(right_wheel_position)\n",
870 " def lookup(self, letter):\n",
871 " a = self.plugboard.forward(letter)\n",
872 " b = self.right_wheel.forward(a)\n",
873 " c = self.middle_wheel.forward(b)\n",
874 " d = self.left_wheel.forward(c)\n",
875 " e = self.reflector.forward(d)\n",
876 " f = self.left_wheel.backward(e)\n",
877 " g = self.middle_wheel.backward(f)\n",
878 " h = self.right_wheel.backward(g)\n",
879 " i = self.plugboard.backward(h)\n",
882 " def advance(self):\n",
883 " advance_middle = False\n",
884 " advance_left = False\n",
885 " if 0 in self.right_wheel.peg_positions:\n",
886 " advance_middle = True\n",
887 " if 0 in self.middle_wheel.peg_positions:\n",
888 " advance_left = True\n",
889 " if 0 in self.middle_wheel.peg_positions and 25 in self.right_wheel.peg_positions:\n",
890 " advance_middle = True\n",
891 " advance_left = True\n",
892 " self.right_wheel.advance()\n",
893 " if advance_middle: self.middle_wheel.advance()\n",
894 " if advance_left: self.left_wheel.advance()\n",
896 " def encipher_letter(self, letter):\n",
898 " return self.lookup(letter)\n",
900 " def encipher(self, message):\n",
901 " enciphered = ''\n",
902 " for letter in message:\n",
903 " enciphered += self.encipher_letter(letter)\n",
909 "execution_count": 548,
915 "enigma = Enigma(reflector_b_spec, \n",
916 " wheel_i_spec, wheel_i_pegs,\n",
917 " wheel_ii_spec, wheel_ii_pegs,\n",
918 " wheel_iii_spec, wheel_iii_pegs,\n",
925 "execution_count": 549,
936 "execution_count": 549,
938 "output_type": "execute_result"
947 "execution_count": 550,
958 "execution_count": 550,
960 "output_type": "execute_result"
969 "execution_count": 551,
977 "output_type": "stream",
979 "a a a ; [16] [4] [21]\n",
980 "a a b ; [16] [4] [20]\n",
981 "a a c ; [16] [4] [19]\n",
982 "a a d ; [16] [4] [18]\n",
983 "a a e ; [16] [4] [17]\n",
984 "a a f ; [16] [4] [16]\n",
985 "a a g ; [16] [4] [15]\n",
986 "a a h ; [16] [4] [14]\n",
987 "a a i ; [16] [4] [13]\n",
988 "a a j ; [16] [4] [12]\n",
989 "a a k ; [16] [4] [11]\n",
990 "a a l ; [16] [4] [10]\n",
991 "a a m ; [16] [4] [9]\n",
992 "a a n ; [16] [4] [8]\n",
993 "a a o ; [16] [4] [7]\n",
994 "a a p ; [16] [4] [6]\n",
995 "a a q ; [16] [4] [5]\n",
996 "a a r ; [16] [4] [4]\n",
997 "a a s ; [16] [4] [3]\n",
998 "a a t ; [16] [4] [2]\n",
999 "a a u ; [16] [4] [1]\n",
1000 "a a v ; [16] [4] [0]\n",
1001 "a b w ; [16] [3] [25]\n",
1002 "a b x ; [16] [3] [24]\n",
1003 "a b y ; [16] [3] [23]\n",
1004 "a b z ; [16] [3] [22]\n"
1009 "enigma.set_wheels('a', 'a', 'a')\n",
1010 "for _ in range(26):\n",
1011 " print(enigma.left_wheel.position_l, enigma.middle_wheel.position_l, enigma.right_wheel.position_l, ';',\n",
1012 " enigma.left_wheel.peg_positions, enigma.middle_wheel.peg_positions, enigma.right_wheel.peg_positions)\n",
1017 "cell_type": "code",
1018 "execution_count": 552,
1026 "output_type": "stream",
1028 "a d t ; [16] [1] [2]\n",
1029 "a d u ; [16] [1] [1]\n",
1030 "a d v ; [16] [1] [0]\n",
1031 "a e w ; [16] [0] [25]\n",
1032 "b f x ; [15] [25] [24]\n",
1033 "b f y ; [15] [25] [23]\n",
1034 "b f z ; [15] [25] [22]\n",
1035 "b f a ; [15] [25] [21]\n",
1036 "b f b ; [15] [25] [20]\n",
1037 "b f c ; [15] [25] [19]\n",
1038 "b f d ; [15] [25] [18]\n",
1039 "b f e ; [15] [25] [17]\n",
1040 "b f f ; [15] [25] [16]\n",
1041 "b f g ; [15] [25] [15]\n",
1042 "b f h ; [15] [25] [14]\n",
1043 "b f i ; [15] [25] [13]\n",
1044 "b f j ; [15] [25] [12]\n",
1045 "b f k ; [15] [25] [11]\n",
1046 "b f l ; [15] [25] [10]\n",
1047 "b f m ; [15] [25] [9]\n",
1048 "b f n ; [15] [25] [8]\n",
1049 "b f o ; [15] [25] [7]\n",
1050 "b f p ; [15] [25] [6]\n",
1051 "b f q ; [15] [25] [5]\n",
1052 "b f r ; [15] [25] [4]\n",
1053 "b f s ; [15] [25] [3]\n"
1058 "enigma.set_wheels('a', 'd', 't')\n",
1059 "for _ in range(26):\n",
1060 " print(enigma.left_wheel.position_l, enigma.middle_wheel.position_l, enigma.right_wheel.position_l, ';',\n",
1061 " enigma.left_wheel.peg_positions, enigma.middle_wheel.peg_positions, enigma.right_wheel.peg_positions)\n",
1066 "cell_type": "code",
1067 "execution_count": 553,
1078 "execution_count": 553,
1080 "output_type": "execute_result"
1084 "enigma.set_wheels('a', 'a', 'a')\n",
1085 "enigma.advance()\n",
1086 "enigma.lookup('h')"
1090 "cell_type": "code",
1091 "execution_count": 560,
1102 "execution_count": 560,
1104 "output_type": "execute_result"
1108 "enigma.set_wheels('a', 'a', 'a')\n",
1109 "ct = enigma.encipher('hellothere')\n",
1110 "assert(ct == 'ilbdartydc')\n",
1115 "cell_type": "code",
1116 "execution_count": 555,
1127 "execution_count": 555,
1129 "output_type": "execute_result"
1133 "enigma.set_wheels('a', 'a', 'a')\n",
1134 "pt = enigma.encipher(ct)\n",
1139 "cell_type": "code",
1140 "execution_count": 556,
1151 "execution_count": 556,
1153 "output_type": "execute_result"
1157 "enigma.set_wheels('a', 'a', 'a')\n",
1158 "enigma.advance()\n",
1159 "enigma.lookup('h')"
1163 "cell_type": "code",
1164 "execution_count": 557,
1172 "('h', 'q', 'q', 'x', 'j', 'z', 's', 'i', 'i')"
1175 "execution_count": 557,
1177 "output_type": "execute_result"
1181 "enigma.set_wheels('a', 'a', 'a')\n",
1182 "enigma.advance()\n",
1183 "a = enigma.plugboard.forward('h')\n",
1184 "b = enigma.right_wheel.forward(a)\n",
1185 "c = enigma.middle_wheel.forward(b)\n",
1186 "d = enigma.left_wheel.forward(c)\n",
1187 "e = enigma.reflector.forward(d)\n",
1188 "f = enigma.left_wheel.backward(e)\n",
1189 "g = enigma.middle_wheel.backward(f)\n",
1190 "h = enigma.right_wheel.backward(g)\n",
1191 "i = enigma.plugboard.backward(h)\n",
1192 "a, b, c, d, e, f, g, h, i"
1196 "cell_type": "code",
1197 "execution_count": 558,
1208 "execution_count": 558,
1210 "output_type": "execute_result"
1214 "pb = Plugboard('')\n",
1219 "cell_type": "code",
1220 "execution_count": 561,
1231 "execution_count": 561,
1233 "output_type": "execute_result"
1237 "enigma.set_wheels('a', 'd', 't')\n",
1238 "ct = enigma.encipher('hellothere')\n",
1239 "assert(ct == 'bahxvfrpdc')\n",
1244 "cell_type": "code",
1245 "execution_count": 562,
1253 "'kvmmwrlqlqsqpeugjrcxzwpfyiyybwloewrouvkpoztceuwtfjzqwpbqldttsr'"
1256 "execution_count": 562,
1258 "output_type": "execute_result"
1262 "enigma.set_wheels('b', 'd', 'q')\n",
1263 "ct = enigma.encipher('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')\n",
1264 "assert(ct == 'kvmmwrlqlqsqpeugjrcxzwpfyiyybwloewrouvkpoztceuwtfjzqwpbqldttsr')\n",
1265 "assert(enigma.left_wheel.position_l == 'c')\n",
1266 "assert(enigma.middle_wheel.position_l == 'h')\n",
1267 "assert(enigma.right_wheel.position_l == 'a')\n",
1272 "cell_type": "code",
1273 "execution_count": 563,
1284 "execution_count": 563,
1286 "output_type": "execute_result"
1290 "enigma.left_wheel.position_l"
1294 "cell_type": "code",
1295 "execution_count": 564,
1301 "# Setting sheet line 31 from http://www.codesandciphers.org.uk/enigma/enigma3.htm\n",
1302 "# Enigma simulation settings are \n",
1303 "# http://enigma.louisedade.co.uk/enigma.html?m3;b;b153;AFTX;AJFE;AU-BG-EY-FP-HL-IN-JZ-OS-QR-TX\n",
1304 "w_enigma = Enigma(reflector_b_spec, \n",
1305 " wheel_i_spec, wheel_i_pegs,\n",
1306 " wheel_v_spec, wheel_v_pegs,\n",
1307 " wheel_iii_spec, wheel_iii_pegs,\n",
1309 " 'ua pf rq so ni ey bg hl tx zj')"
1313 "cell_type": "code",
1314 "execution_count": 566,
1321 "output_type": "stream",
1332 "execution_count": 566,
1334 "output_type": "execute_result"
1338 "w_enigma.set_wheels('j', 'e', 'u')\n",
1339 "ct = w_enigma.encipher('hellothere')\n",
1341 "assert(ct == 'wzmfiwuntn')\n",
1346 "cell_type": "code",
1347 "execution_count": 568,
1355 "'ayraqvsfkhflwsmkqicvfwawswmiwvvlteb'"
1358 "execution_count": 568,
1360 "output_type": "execute_result"
1364 "w_enigma.set_wheels('n', 'y', 'q')\n",
1365 "ct = w_enigma.encipher('hellotomweshouldgetbeerorcoffeesoon')\n",
1370 "cell_type": "code",
1371 "execution_count": null,
1381 "display_name": "Python 3",
1382 "language": "python",
1386 "codemirror_mode": {
1390 "file_extension": ".py",
1391 "mimetype": "text/x-python",
1393 "nbconvert_exporter": "python",
1394 "pygments_lexer": "ipython3",