0 Ho it works (kinda)
vanitasvitae edited this page 2016-03-24 20:27:09 +01:00

The Enigma Machine is a typewriter-like machine used to encrypt text messages. It had a keyboard with 26 keys and the letters A-Z and a board of 26 bulbs also numbered A-Z. On the top of the machine were some slots were the user could install 3 to 8 rotors. A rotor is a disk with a ring of 26 metal contacts on both sides. The contacts were pair-wise connected in a very specific order. Every rotor had a label around it, in order to know its rotation (also labeled A-Z). On the front of the machine was a board with 26 pairs of plugs that could be connected by hand with short cables. This was called the plugboard. It reminds a little bit of an old telephone switchboard.

When the user wants to write a secret message, he just has to set up his enigma machine by setting it into a specific configuration. This can be chosen randomly, but it was common practice to have a little booklet or a list of configurations for every day. The enigma is a symmetric cryptosystem, that means sender and recipient of a message must share a secret, in this case the configuration. So the sender choses some rotors and some rotations for every rotor. Optionally he choses a plugboard setting. He does so by connecting up to 11 characters with cables. Then he is ready to go.

What happens mechanically is really straight forward, but I find it hard to explain by words, so I will link a video which explains it very nicely.

https://www.youtube.com/watch?v=G2_Q9FoD-oQ

I implemented it basically with a lot of integer arrays. I adopted every rotor as two arrays of length 26. One array was used to encode in one direction, the other one was the inverse permutation of the first. It encodes the backwards direction.

The same I did for the plugboard. If the user swapped letters A and B, I swapped array entries A and B in the plugboards arrays.

The position of the rotors was implemented by painfully working out where to add an offset to which index and where to subtract it and so on and so forth. It was really terrible...

So what happens is the following: The rotors rotate. The next input character is an X. X translates to say G in the plugboard. G translates to J in the first rotor. The second rotor translates J to R. R becomes B in the third rotor, which hands it over to the "Umkehrwalze" which translates it into a P. The P now enters the third rotor backwards and becomes a V. V becomes A in the second rotor, A becomes U in the first rotor, which translates to I in to plugboards and there we go - X just got I. If the user had typed I instead of X, we would have become an X out of the machine.

If you want to read more about this and you are somewhat able to read German, I'd recommend the german wikipedia article about the enigma machine. It is very detailed and helped me a lot.

I hope this clarifies somewhat how my app works :)