Of course the real test is to see if you can decrypt

This preview shows page 5 - 7 out of 7 pages.

Of course the real test is to see if you can decrypt what you encrypted. Otherwise you have an unbreakable, but utterly worthless cipher.
Image of page 5

Subscribe to view the full document.

To decrypt, you'll either need rotor arrays initialized “backwards” to match the ones you used for encryption, or you'll have to figure out how to make the “reflector” technique described in the reference for ENIGMA work. Hint: (I think, but I have not tried this, that reflection is emulated by doing this: / / Forward through the three rotors step1 = rotor1 ( inputChar ) ; step2 = rotor2 ( step1 ) ; step3 = rotor3 ( step2 ) ; // Now back through three rotors step3 = rotor3 ( step3 ) ; step2 = rotor2 ( step3 ) ; step1 = rotor1 ( step2 ) ; printf ( “%c”, step1 ) ; With this setup, and assuming that my emulation logic is correct, you should be able to decrypt by passing the ciphertext back through your ENIGMA emulation with the same initial rotor settings. Should be fun to try, anyway. Hint: Eventually you should use a text file as input – this will save tons of typing in the long run. To do so, Google standard C library functions fopen and fgets . Like scanf, fgets reads an input into a variable, but it reads an entire line (up to and including the newline) into a character string (array). The fopen function lets you tell fgets which file to read from, rather than just reading from the keyboard like scanf. Hint: Filter the input for non-letter characters and just pass these through unchanged. Although this is a poor encryption practice it will make your program simpler and the output easier to check. Hint: Use the toupper C library function to make all letters uppercase, which will cut the size needed for your rotor arrays in half. Good luck and have fun enciphering messages. Afterthoughts This is a C class, and this problem can be solved using plain vanilla C. However, it would also lend itself to an Object Oriented approach using C++ for a couple of reasons. Mainly, the required emulation of a physical machine with its rotors and plug-boards makes some useful objects apparent. The ENIGMA machine could be modeled as a Machine Class, a composite object that has (contains) other objects, such as rotors, plug-boards, and input and output streams. As an object a Rotor would have a constructor that initializes the rotor configuration and position, and then accessor methods that return the next enciphered character, turn the rotor, reset the rotor to the initial position and so forth. The Machine, as a container object could support a variable number of Rotors, and would be responsible for interconnecting them by means of their positions. A
Image of page 6
plug board could be an object that models a simple initial permutation of a subset of input characters. In many cases, software objects are best conceptualized as “machines” that respond to inputs (like a Soda machine or an ATM) but whose inner workings can remain a black box except for those who need to know.
Image of page 7
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