During my mathematics BSc, one model focussed on VBA and PHP programming. As a part of that model, I wrote a simple digital version of the Enigma encryption machine used in World War II.
As the module focussed on VBA in Excel, a makro enabled spreadsheet carries the code. The rotors are supplied separetly in a folder named "Rotors" and consist of plain text. The names are hardcoded, however the content of the text files can be changed.
Usage via the userform should be self explanatory, for those interested, a description below.
How it works:
Each rotor in Enigma is a mechanical implementation of a simple substitution cipher, the input letter is mapped to a different letter. With three rotors, this step happens three times, with four rotors four times. The genius of Enigma is that at every input, the first rotor steps forward by one step and the second steps forward after the first took 26 steps. This has the effect of changing the ecryption key at every letter as with a rearrangement of the rotors, as every step leads to a new mapping.
Because the initial rotor position is arbitrary, even when the rotor wiring is known, three rotors have 17576 different starting positions. Adding a fourth rotor, even when static leads to 456976 initial starting combinations.
In addition, one has a choice of rotors, using a set rather than all available rotors and a conection board where letters can again be remapped.
Yes, Enigma is not foolproof, it has been cracked using the mathematics of Marian Rejewski and his colleagues from Poland and was then regularly decrypted in Bletchley Park in the UK in World War II. However the decryption was to some extent a clever brute force approach which relied on pre-obtained knowledge about the ecnryption (code books, wiring, patterns in messages.)