Enigmatics

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.

Unfortunately, there is a bug in this implementation, because the method of "rotating" a scramber wheel (by naively using RotateRight[...,1]) does not rigidly rotate the wheel's internal wiring, but mangles it up so that the wiring depended on the wheel's orientation.

Load the Combinatorica` package in order to manipulate permutations and cycle structures.

"BE3409298687_1.gif"

Define the initial state of the 3 scrambler wheels. Each is a random permutation of 26 letters.

"BE3409298687_2.gif"

"BE3409298687_3.gif"

"BE3409298687_4.gif"

"BE3409298687_5.gif"

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.

"BE3409298687_6.gif"

Define the reflector. Create a random permutation of 26 letters, partition it into 13 2-cycles, then convert this into the corresponding permutation.

"BE3409298687_7.gif"

"BE3409298687_8.gif"

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.

"BE3409298687_9.gif"

Define some "enigmatic" message text.

"BE3409298687_10.gif"

Convert it to a list of character codes offset so that "A" is 1.

"BE3409298687_11.gif"

"BE3409298687_12.gif"

Encode the list of character codes starting at time 0.

"BE3409298687_13.gif"

"BE3409298687_14.gif"

Convert the encoded list to cipher text.

"BE3409298687_15.gif"

"BE3409298687_16.gif"

Concatenate all of the above operations to define the Enigma machine encoding function for a whole message.

"BE3409298687_17.gif"

Verify that the cipher text decodes correctly.

"BE3409298687_18.gif"

"BE3409298687_19.gif"

Verify that the cipher text decodes incorrectly if the scrambler wheels start off in the wrong state.

"BE3409298687_20.gif"

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


Links
COMMENTS

 

Blogged from
A WorkLife FrameWork by
Scientific Arts

All material on this website Copyright © 2008, Stephen Luttrell.