Share
Explore BrainMass

Enigma Machine implementation in C

Write a software implementation of a simple three rotor Enigma Machine. Please refer to the following wikipedia entries for the Enigma Machine and the Enigma Rotor details.

http://en.wikipedia.org/wiki/Enigma_machine
http://en.wikipedia.org/wiki/Enigma_rotor_details

For the current implementation, consider only the rotors I - V, and the stock B & C reflectors. For sake of convenience, our message format will contain everything including the settings, as explained below.

machine_settings ( reflector, left rotor, middle rotor, right rotor )
initial_position encrypted_message_indicator
message ( this may be more that one line )

For example :
B I II III
AAA AAA
ZZZZZ ZZZZZ ...

The initial position is where the rotors start, the encrypted message indicator is the input then, and the resulting values would be the message indicator. That indicator becomes the initial position for the message. Historically the message body was written as 4 or 5 letter groups.

Kindly refer to the attached document ("Enigma Machine.doc") for detailed explanation of encryption logic using examples.

Attachments

Solution Preview

Attached 152594.c compiles correctly with "gcc -Wall -ansi", and has ...

Solution Summary

Attached program compiles with 'gcc -Wall -ansi' without any errors and warnings (tested with gcc 3.3.1 on cygwin), and has been tested for inputs given in the document, with and without '-vvv' argument to the compiled program.

$2.19