sample input is like enigma and output is anigme
Answers
Answer:
This article is adapted from Chapter 12 of my unpublished textbook Applied Algorithms and Data Structures.
Part of the presentation and the figures are from Bauer, F.L., Decrypted Secrets, pp. 106-108, Figures 49, 50, and Plates I, K.
The ENIGMA enciphering/deciphering machine was patented in Holland in the fall of 1919 by Hugo Koch, who sold the patent to the German engineer Arthur Scherbius, who in turn filed for a patent in 1926 (US patent number 1,584,660). There were commercial and military versions of this machine, which is famous for having been used by the German armed forces (Wehrmacht, Kriegsmarine, and Luftwaffe) and by the intelligence service (Abwehr) during World War II. The machine is also famous because the British cryptographers at Bletchley Park, most notably Alan Mathison Turing, were able to crack the ENIGMA code (with substantial initial help from Polish mathematicians who had been given an ENIGMA machine). It is beyond the scope of this article to recount the fascinating history of the codebreaking of ENIGMA. (The interested reader is referred to the book by Bauer, the chapter titled “The COLOSSUS” by B. Randell in Metropolis, N., et al. A History of Computing in the Twentieth Century. New York: Academic Press, 1980, and the following books (to name a few): Welchman, G. The Hut Six Story: Breaking the Enigma Codes. New York: McGraw-Hill, 1982. Garlinski, J. The Enigma War. New York: Charles Scribner’s Sons, 1979. Kahn, D. Seizing the Enigma. New York: Houghton-Mifflin, 1991. Sebag-Montefiore, H. Enigma: The Battle for the Code. New York: John Wiley and Sons, 2000. Budiansky, J. Battle of Wits: The Complete Story of Codebreaking in World War II. New York: The Free Press, 2000. For technical details on the breaking of the code, the master himself is the source: on the world-wide web, R. Erskine, P. Marks, and F. Weierud have edited and put available the document “Turing’s Treatise on Enigma” from the original documents in the National Archives.) This article deals with the development of a simulator of the ENIGMA machine.
The ENIGMA machine, shown in the figure below with its cover closed, is a rotor crypto-machine. It consists of a typewriter, a set of lamps labeled with letters in front of the typewriter keys, a set of rotors (partially hidden by the cover) in front of the lamps, and a plugboard on the front vertical wall of the box. The plugboard was a later addition to the machine to provide one more encryption step by associating pairs of letters.