Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SPECIFICATIONS The project can be divided into discrete sections. There is however considerable overlap. Each section or block can comprise of one or more procedures.

SPECIFICATIONS The project can be divided into discrete sections. There is however considerable overlap. Each section or block can comprise of one or more procedures. However, you should ensure that whilst writing your procedures you ensure that you and your compatriots expect the same inputs and outputs. Writing small test benches to test the function of each procedure or block of procedures prior to integration is a good idea. The largest and most complex is the encryption block. Particularly if the simpler input strategies are used for the message. You are encouraged to plan the design and structure of the code before you start work on the actual code. 1. You need to decide if your program will accept input as:

A String In this case you need to read in a string of no more than 255 characters.

From a file In this case you will need to use the file handling routines to open, read and close the file to extract the information. This is the most difficult approach. The program will need to be told the rotor start point and step values. It will also need to know if it will encrypt or decrypt the message. 2. You need to decide how the output block will output the information: As a string As a file 3. The encryption block We are going to use a basic cipher similar to the enigma systems used during World War II. This is to give us a chance to debug if things go wrong. The intention is to design the blocks for a single rotor in a manner that allows us to connect two or more rotors in series for a stronger cipher. 4. Enigma How does a Rotor work? A rotor works by having a set pattern of mappings so that when a letter is entered it is changed to another letter. Our system needs to accept both letters, upper case and lower case, numbers and special characters like the ., and other punctuation. At this state, we are looking at what was termed Caesars cipher a basic substitution cipher where the same letter is always substituted for one that is entered. This is a very weak cipher. The German enigma machines produced a stronger cipher by changing the mapping after each letter. Like the Roman cipher this is a reversible cipher in that a cipher machine with the same information allows us to decrypt the message. In order to ensure that a message can be encrypted, or decrypted we must be able to set the Rotor to an initial state before we start encoding or decoding a message. 5. Modeling the system If we model the rotor as an array which starts from 0 and runs to 100. Then we step along the array for the rotor. When we reach 100 we wraparound to 0 and carry on. Mimicking the effect of the rotor coming full circle. We can change the cipher key in two ways: By changing where we start on the array By changing how we step for each character for example +1, -1, +2,-2 Either of these will change how the message is encrypted. It will not make the cipher harder to crack it will just change the cipher key. Hence if we have the same rotor sequence (sequence of numbers in the array) then we need to know the starting position and the step before we can successfully decrypt the message. 6. Using ASCII Code: We have already seen that an character has both an alphabetical i.e. a,b and a numeric value i.e. 25,35. We have also seen that the alphabetical characters have a defined numerical value as ASCII. We can use this to our advantage. The section of the ASCII map we are interested in starts at 32, a space and ends at 126. 127 is deleting and should be avoided. How do we use this? The range of input values for the alphabetical characters should be between 32 and 126. The range of output values for the alphabetical characters should be between 32 and 126 Example The following is an example of using this system for encryption and decryption. For this example I will use a short rotor with 3 elements, we can define the rotor using: Unsigned Char Rotor [3]=[3,-6,+2]; The message to be encrypted is Hello The rotor start position is 0 and the step size is 1. The first letter H is to be encrypted with 3. The ASCII value of H is 72, 72+3 = 75. Which is K. The rotor now moves one forward and we process the second letter e The ASCII value of e is 101, 101 6 = 95. Which is _. The rotor now moves one forward and we process the third letter l The ASCII value of l is 108, 108 + 2 = 110. Which is n. We now loop back to the start of the rotor. If you are using non unit steps for the rotor movement then you need to be careful at the boundaries as shown below for the ASCII wraparound. The rotor now moves one forward and we process the fourth letter l The ASCII value of l is 108, 108 + 3 = 110. Which is m. Notice that the same letter has now been encrypted to a different letter in the encrypted message. Notice also that we are reusing the rotor positions. Decryption Decryption is relatively straight forward. Instead of adding the value to the letter we subtract the value from the encrypted letter. Remember that a is a + operation. Hence the first bit of the encrypted message in our example above is: K_nm 75 -3=72=H 101 - - 6=107=e And so on. Again we will need to define if we are encoding or decoding a message so the correct operation is carried out. Possibly we could use a question at the start. What happens if the ASCII value that we calculate is > 126 or < 32: In this case we wrap around and start from the top or bottom. Hence Value = A + B If Value > 126 Value = (Value 126) + 32 Else If Value < 32 Value = 126 - ( 32 Value ) Think carefully about the calculations to ensure you do them correctly. Use the algorithm and put some test cases through the examples. For example Value = 152 Value = 152 -126 + 32 Value = 58 Value = 10 Value = 126 ( 32 10) Value=104 7. Thinking about the procedures If we look at structuring the design so we can use multiple rotors this forces us to consider the internal structure. We need to pass in the start position and the step for each Rotor. Each time the rotor is used in encoding the message we need to update the rotor position and to return the character that has been encoded. Careful planning at this stage and the division of the tasks will pay dividends. 8. Rotor Sequences In order to ensure we all use the same rotors I will define the sequence to be used: Rotor 1: 59, 88, 28 ,31 ,49 ,69 ,58 ,15 ,45 ,81 ,20 ,57 ,46 ,25 ,87 ,3 ,4 ,1 ,11 ,83 Rotor 2 83, 41, 66, 65, 96, 2, 8, 93, 40, 70, 55, 24, 90, 95, 34, 89, 98, 24, 44, 85 Rotor 3 58, 91, 18, 60, 36, 54, 100, 90, 47, 50, 12, 52, 62, 78, 57, 18, 35, 36, 33, 43 Multiple Rotor Systems When using multiple rotors, the next rotor will only increment when the previous rotor has gone around a complete cycle. Like a binary counter. The Enigma Application must be able to do these functions: 1. Allow the user to enter a message either as a string or in a file. 2. Encrypt the message. 3. Write the encrypted message either on the screen or in a file. 4. Read the encrypted message either as a string or in a file 5. Decrypt the message. 6. Write the decrypted message either on the screen or in a file. Key Functions Your system should contain the following Functions: 1. Allow the user to enter a message. 2. Encrypt the message. 3. Decrypt the message. 4. Display the encrypted or decrypted message to the user. REQUIREMENTS: Model the Enigma Application: Make sure you read through all of the specifications and extract the key pieces of information. Be on the lookout for processes that repeat themselves in various locations, this can be helpful to apply modularization techniques. Consider the various messages that the system is required to produce and document them.

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

Strategic Database Technology Management For The Year 2000

Authors: Alan Simon

1st Edition

155860264X, 978-1558602649

More Books

Students also viewed these Databases questions

Question

Evaluate 3x - x for x = -2 Answer:

Answered: 1 week ago

Question

What is group replacement? Explain with an example. (2-3 lines)

Answered: 1 week ago