Write a c program to implement a substitution cipher to


Assignment

Write a C program to implement a substitution cipher to encrypt plain text:

• Select a string of characters to use as the cipher key, which must be 2 to 16 characters in length and contains only lower case characters of the alphabet (a-z) without any duplicates

• Select a string of plain text to encrypt, which must be 4 to 256 characters in length and contains only lower case characters of the alphabet (a-z) and spaces

• Use N to indicate the current position in the cipher key, where the starting position (first character) is indicated by N equal to 1.

• Perform the encryption by implementing these steps from the start of the cipher key:

1) The character found at position N in the cipher key is the target value

2) The character found at position N+1 in the cipher key is the substitution value; in the situation that N is the last character in the cipher key, then, the substitution value is the first character of the cipher key

3) In the plain text, replace all instances of the target value with the substitution value

4) Increase N by one and repeat all steps until the end of the cipher key The program must read the following input:

• 1 st line of input is a number indicating the length of the cipher key
• 2 nd line of input is the cipher key text
• 3 rd line of input is a number indicating the length of the plain text
• 4 th line of input is the plain text to be encrypted The program must display the following output:

• The number of each step, e.g. if the length of the cipher key is 4, then, the output must display substitution steps 1, 2, 3 and 4
• The target value and the substitution value at each step.

• The encrypted text at each substitution step Sample input 2 hg 11 hello world Sample output

Step 1 substitute h with g gello world
Step 2 substitute g with h gello world Sample input 3 hgw 11 hello world Sample output

Step 1 substitute h with g gello world
Step 2 substitute g with w gello world
Step 3 substitute w with h gello horld 2017-18

Sample input

4 hdgw 11 hello world

Sample output

Step 1 substitute h with d dello world
Step 2 substitute d with g dello worlg
Step 3 substitute g with w dello worlg
Step 4 substitute w with h dello horlg

The coursework must contain pseudo code of the solution at the top of the program (enclosed with source code comments delimiters). Source code comments are required to explain the implementation.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Write a c program to implement a substitution cipher to
Reference No:- TGS02746975

Expected delivery within 24 Hours