Weve modeled a physical rotor with a program data

This preview shows page 4 - 6 out of 7 pages.

We've modeled a physical rotor with a program data structure, an array. But our rotor is “stuck” in one position. In my simple example, U will always result in A, and the cipher will be broken easily. How can we simulate a rotor turning? Well, we could move all the elements in the array “down” one element and then take the last element and “wrap it around” to become the first element. This simulates “rotation”. It's easier than it sounds. Here's a picture:
Image of page 4

Subscribe to view the full document.

Index Input Step1 Step2 Step3 0 a x z y 1 b c x z 2 c d c x 3 d i d c 4 e y i d 5 f z y i --- z y In the table above, index is the actual subscript into the array. Input is the character that is to be translated (enciphered). Steps 1, 2 and 3 show the scrambled values in each element of the array. These are the values that will be substituted for the input characters. So in Step1, 'a' will be replaced by 'x', 'b' by 'c', ... and 'f' by 'z'. So far this is just like the earlier example with the “stuck” rotor. But now we'll step the rotor one position. To do that, slide all the elements of the array to the next higher position. The 'x' moves from index 0 to index 1. The 'c' moves from index 1 to index 2, and so forth until you get to index 5. Here's the trick to rotation . Take the element that was in 5 before the rotation ('z') and rotate it around to fill in the slot for index 0, which was emptied when the 'x' that was there before shifted down one position. Now after Step2, the input letter 'a' will become not 'x' as in Step 1, but instead will become 'z'. An input of 'f' will encipher not to 'z' as in Step 1, but will instead encipher to 'y',. This is the key to ENIGMA ciphers and why they can be so effective – the same character does not substitute each time. In fact, the output character depends on how many steps have come before. Hint: So first build an array that models the “stuck” rotor and get that fixed encipherment to work. Then add the logic to “turn” the rotor by the logic shown above. Get that to work. Hint: If you think back to the discussion about the arithmetic required to use an array that starts not at zero, but at say, 85, then you may see a way to make the array appear to rotate without actually moving any elements other than the first (0) and last . With the right, simple calculation, you can adjust the input to achieve the same effect as rotating the array . But this is an optimization and is not strictly required. Hint: Make the rotor a function, with a parameter that is the letter to be enciphered. You'll need to make the rotor array static in that function, and you may need other static variables as well. The output (return value) from the function is the enciphered character. Hint: Once you get this to work, duplicate the rotor function to make a new function featuring a different “scrambling” of the elements in the rotor array. Then use the output of function rotor1( ) as the input to rotor2( ), and you're on the way to your own ENIGMA.
Image of page 5
Image of page 6
You've reached the end of this preview.
  • Spring '08
  • GeraldReed
  • Cryptography, Array, Enigma machine, rotor, Enigma

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern