Simple implemention of an Enigma machine and a cracker that determines the most likely rotor position given encrypted text.
npm install
npm test
By far the most complex part of the implementation. Our example uses 3 rotors but could easily support as many as needed if alphabets were provided.
- The inverse of a character must always be reflected back to the same original character. Example: With a given rotor setting, A -> G then G -> A. This is so the machine can be used for both encryption and decryption.
- The first rotor must move quickly and each subsequent rotor must move 1/25 of the previous rotor. So given no settings, [ 1, 0, 0 ] would be the first move until it reached [ 25, 0, 0 ] at which point it would switch to [ 0, 1, 0 ].
- If the last rotor reaches 25, all rotors must reset back to 0. This makes the machine infinitely usable.
Very simple swapping of two characters. Provided to the class in a string like 'ad cm ey kp'. This would switch A -> D and D -> A respectively.
Uses the index of coincidence (IOC) to determine the most likely rotor setting by trying all possible combinations and returning those with the highest likelihood.