Home
 
Projects
 
About Me
 
Contact Me
 

Enigma Machine

Introduction

During World War II, the Germans had an unbreakable code machine that the Allies could not defeat until they captured a physical copy of the encryption device. This device is one of history's most famous encryption systems - the Enigma. More information on the enigma can be found here.

The Encryption

To follow along with this section, you may visit a flash implementation of the Enimga machine here.

The encryption itself is composed of a few parts. Firstly, the letter you enter into the device undergoes an arbitrary transformation. This transformation is known in advance, based on the third rotor in the machine. Now each time we type a letter, the rotors will move based on the following pattern:

  • Every time a letter is entered, the third rotor turns.
  • Every time the third rotor hits 'W', the second rotor turns.
  • When the second rotor is on 'E' and a letter is entered, it rotates to 'F'. This is a special rule (double stepping)
  • When the seconds rotor hits 'F', the first rotor turns.


  • Knowing how the rotations work is the hardest part. Now we just need to convert it to something programmable. We can do this by simply storing the rotors as strings, and keeping track of the rotor offsets.

    Implementation

    After figuring out the subtleties of the Enigma machine, the implementation was actually fairly simple. It was only about 200 lines of ASM and I'm sure there are more efficient implementations.

    You can download my implementation of the Enigma Machine in assembly language here: enigma.zip(3.79 KB).
    (Note that there is an additional include file which contains some pre-made procedures to write data to the console. You will need it to run the Enigma.)

    More coming soon...
    coming soon...