|
Enigma machine
Posted on: Monday 14/1, 2008; 11:24 AM
This is adapted from Figure 36 of The Code Book by Simon Singh. The Enigma machine itself is modelled as a discrete time dynamical system. However the time series of inputs and outputs are treated as whole lists (with no particular starting time index) rather than as sequences of individual values (with a definite starting time index). For instance, this makes it easy to feed different inputs to an Enigma machine starting in the same state, because there is no need to erase any previous inputs and outputs.
Load the Combinatorica` package in order to manipulate permutations and cycle structures.
Define the initial state of the 3 scrambler wheels. Each is a random permutation of 26 letters.
Define the update rules for the scrambler wheels. Because this behaviour is periodic it would be much more efficient to compute the state at any time directly from the initial state, without going through all the intermediate time steps as is done here to illustrate the evolution of a discrete time dynamical system.
Define the reflector. Create a random permutation of 26 letters, partition it into 13 2-cycles, then convert this into the corresponding permutation.
Define the Enigma Machine encoding function for a single character (as a code in the range 1-26). Propagate forwards through the 3 scrambler wheels, through the reflector, then propagate backwards through the 3 scrambler wheels again.
Define some "enigmatic" message text.
Convert it to a list of character codes offset so that "A" is 1.
Encode the list of character codes starting at time 0.
Convert the encoded list to cipher text.
Concatenate all of the above operations to define the Enigma machine encoding function for a whole message.
Verify that the cipher text decodes correctly.
Verify that the cipher text decodes incorrectly if the scrambler wheels start off in the wrong state.
| 0 |
ANDWHENHELAIDEYESONHERHEGOTTHEFEELINGTHEYHADMETBEFORE |
| 1 |
HRNGXEYOIFPIWXCJMOWFIVJPPMSSBSTLCVPXETPDHGJDUEAVEFCIJ |
| 2 |
KWRAGORRIOJMTUETVSMHKVNITMRGZCDFKFJHDZXJGUIDINUCKLQHI |
| 3 |
TGTJNZOASEJMJKCNLSVLIFSGSMXIHGHDSDQFCZXRUWWMSMSWKFLST |
| 4 |
IARZQSEPDNNWRSEWUCCQKQLARVFSPNOLSCKEIZXFWGYLWAAULMANO |
| 5 |
CJTIZPMJWUNHBCIMBNFAOALHXUTCPHITSBIDQIDPGQIZDCIRFGPCD |
| 6 |
CZXPOFWJTXXAFGNVEGOUMHUBFIDAPOPTYHQJEHDTQOSBXMHBKLARS |
| 7 |
GICSINANJGIXHIXCNDDSMBTZTKHZVIJTYPYROVDAONQLEYDJJKGCD |
| 8 |
GPMBIXCNRVBNFGRFCTRRMIHHDUOYVGHZYDYFSXMUNMPVVNVFUVUIJ |
| 9 |
QSGQMBAXBPYVHIAOWFQFVCJPHEIEVOPZHNYPZHLBMSOMYYIXPQGWX |
| 10 |
BBPKMDCIFPOFLMQDPZWHUATPOCPMEWXZGRETTRZVSAOXTEPKEFXIJ |
Permalink Notebook
|
Recent Posts |
11/1, 2008; 3:43 PM: Enigma 1476 7/1, 2008; 9:11 PM: Enigma 1475 21/12, 2007; 4:40 PM: Enigma 1474 14/12, 2007; 1:36 PM: Enigma 1473 9/12, 2007; 12:40 PM: Enigma 1472 2/12, 2007; 11:55 AM: Enigma 1471 1/12, 2007; 5:33 PM: Enigma 1467 29/11, 2007; 3:27 PM: Enigma 1469 29/11, 2007; 2:12 PM: Enigma 1468 29/11, 2007; 1:09 PM: Enigma 1465 27/11, 2007; 8:39 PM: Enigma 1462 27/11, 2007; 8:38 PM: Enigma 1464 27/11, 2007; 8:35 PM: Enigma 1463 27/11, 2007; 8:23 PM: Enigma 1461 27/11, 2007; 8:19 PM: Enigma 1460 27/11, 2007; 8:14 PM: Enigma 1459 27/11, 2007; 8:09 PM: Enigma 1458 27/11, 2007; 7:42 PM: Welcome
Archive |

Blogged from
A WorkLife FrameWork by
Scientific Arts |