Question: could you create a c + + program : DO NOT use functions, vectors, arrays, or any additional techniques we have not discussed in class.
could you create a c program :
DO NOT use functions, vectors, arrays, or any additional techniques we have not discussed in class.
The user will enter the name of a file that contains a random series of characters the onetime pad The user will then choose to encrypt or decrypt a message using that pad. The message is entered and the result is displayed.
The Process
Prompt the user for the filename. The user should enter a local filename.
Which file would you like to use?
Prompt the user for encryptiondecryption The user should enter an E or a D
Would you like to Encrypt or Decrypt
if encrypt
Open the OneTime Pad OTP file
Prompt the user for a plain text string to encrypt
Enter the plain text string:
Read the plain text PT string from input
Map next PT character from to
Read character from OTP
Map OTP character from to
Get the cypher text CT character by adding OTP char to the PT char
Modulo the CT back to range if CT CT CT
Map CT char from to
Display CT char
If there are more PT chars, go back to step
Close OTP file
if decrypt
Open the OneTime Pad OTP file
Prompt the user for a cypher text string to decrypt
Enter the cypher text string:
Read the cypher text CT string from input
Map next CT character from to
Read character from OTP
Map OTP character from to
Get the plain text PT character by subtracting OTP char from the CT char
Modulo the PT back to range PT PT PT
Map PT char from to
Display PT char
If there are more CT chars, go back to step
Close OTP file
Note: You may assume for this project the OTP file and the entered message are well formatted and contain no errors.
Mapping
Moving a value from one range to another, or mapping the value, means to take a value x in one range, inMin inMax and calculate the equivalent value y in a new range, outMin outMax The formula is
yxinMinoutMaxoutMininMaxinMinoutMin
The Example
for encryption
Which file would you like to use? OTPTest.txt Would you like to Encrypt or Decrypt E Enter the plain text string: Bob is cool kx:UvKZ
for decryption
Which file would you like to use? OTPTest.txt Would you like to Encrypt or Decrypt D Enter the cyper text string: kx:UvKZ Bob is cool
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
