The Enigma machine was invented by the German engineer, Arthur Scherbius, in 1918. It has a keyboard which is connected to a lampboard by wires. Each letter has a connection which leads to another letter.
However, this would only produce a substitution code, which could easily be cracked. An Enigma machine had three or four rotors, so that each letter was changed three or four times. Each rotor moves on one place after each revolution, so a given letter will be encrypted differently each time. They also had a reflector, which reversed the signal back through the rotors, encrypting the message one more time.