WeChat:lovexc60
COM3190/COM6116 Programming Assignment
Erl-nigma – A simulated Enigma machine
Ramsay Taylor
Department of Computer Science
The University of Sheffield
DEADLINE: 3.00pm, Wednesday, Week 12
Guidelines
This assignment contributes 30% towards your overall module mark, and requires you to submit
TWO files: (a) a single PDF document answering Part 1 below; (b) a single Erlang program file
containing your solutions to Part 2. You should submit your solutions via MOLE no later than
the deadline specified above. Standard penalties will apply for late submissions.
Background
The Enigma machine was invented in Germany in 1918, and uses various mechanical and electrical
components to encrypt and decrypt messages, one letter at a time. Originally developed for
commercial use, it was soon adapted for military and diplomatic purposes (Figure 1a) [5].
(a) Enigma (b) Plugboard
Figure 1: (a) A Military Enigma Machine [6]. (b) Plugboard [3]. The wires shown here swap A
with J, and S with O.
1
Figure 2: Rotors [2].
Components
Figure 3: An outline of the Enigma process
Figure 3 shows the basic components of an Enigma machine and their interconnections:
Keyboard
The machine has a keyboard, on which users type their plaintext messages.
Plugboard
The plugboard is used to set up a basic substitution cipher. In Figure 1b, for example, a wire
has been used to join the sockets labeled A and J. This means that every time the user
types the letter A, the keyboard actually produces the letter J (and vice versa). Similarly,
because there is a wire joining sockets S and O, typing the letter O actually produces the
letter S (and vice versa).
Rotor
The machine is equipped with several rotors, which again perform simple letter-for-letter
substitutions. Each rotor is connected to the next by electrical contacts, and the result of
sending a letter through all of the rotors, one after the other, depends on their positions
relative to one another (Figure 2). The power of the Enigma machine comes from the simple
tactic of changing the relative positions of the rotors after each letter has been encrypted.
Just because E generated the output Z last time (say), doesn’t mean it will generate the
output Z this time, because the rotors will have rotated relative to one another.
Reflector , Lampboard
Once the current letter has been transmitted through the plugboard and rotors, it is passed
through a reflector (this again connects letters together in pairs). Having passed through the
reflector, the letter undergoes further encryption by being passed back through the rotors
and plugboard. On reaching the keyboard, the built-in lampboard shows the user which
letter should be used to encrypt the letter they just typed.