Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 3 - Enigma For this task, you need to implement a simplified version of the famous Enigma cipher that was used by the axis

Task 3- Enigma
For this task, you need to implement a simplified version of the famous Enigma cipher that was used by the axis powers in WWII. The cracking of the Enigma cipher was also a seminal moment in the history of computer science. You can learn a bit more about this in the History section on Enigma.
For a detailed explanation of the workings of this cipher, first read our write-up in the Enigma Operation for this PA section. This will provide you with all the details you need. Make sure you thoroughly understand the Enigma operation before you go on to the coding part. Note that the Enigma treats spaces just like other characters (so we are again working with a set of 27 symbols, as with the substitution cipher). Again, index_of_char() and char_at_index() will be extremely helpful in implementing your code.
The function you need to implement has the following functionality:
cipher_enigma(arg1, arg2, arg3, arg4)
The first argument, arg1, is a string containing the data that needs to be encrypted or decrypted. It is not modified by this function.
The second argument, arg2, is a string that will contain the result of the encryption or decryption.
The third argument, arg3, is a non-negative integer number (of at most 4 digits), specifying the key of the Enigma cipher. The two rightmost decimal digits (what are called the least significant digits) of this number represent the initial shift (to right!) of the inner rotor (what we called key_part_1 in Enigma Operation for this PA). The next two digits give the initial shift (to the right) of the middle rotor (what we called key_part_2). For example, the number 1329 means that the initial shift of the inner rotor is 29 positions (which is the same as 2 positions, as it wraps around after 27 turns) and that of the middle rotor is 13 positions. So the following keys all result in the same starting positions of the rotors: 1302,1329,9483, etc.
For the fourth argument, arg4, which is an integer, we either pass ENCRYPT or DECRYPT, which are the two constants that we defined.
The function returns nothing.
The default positions for all the rotors (i.e., without any initial shift) and the organization of the symbols on each of the rotors is as shown in Enigma Operation for this PA. This information is also already included in the ciphers.c starter code, so you dont have to copy it from this document. When testing your Enigma, make sure it also works for messages longer than 27 symbols (to capture the effects of the rotors moving after encrypting each symbol).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Entity Alignment Concepts Recent Advances And Novel Approaches

Authors: Xiang Zhao ,Weixin Zeng ,Jiuyang Tang

1st Edition

9819942527, 978-9819942527

More Books

Students also viewed these Databases questions

Question

How can environmental selfidentity be strengthened?

Answered: 1 week ago

Question

What are the types of forms of communication ?

Answered: 1 week ago

Question

Explain the process of MBO

Answered: 1 week ago

Question

Is conflict always unhealthy? Why or why not? (Objective 4)

Answered: 1 week ago