IntroductionDuring 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 EncryptionTo 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:
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.
ImplementationAfter 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...