Question: To develop a C program that can encrypt and decrypt text using the Caesar cipher technique. This assignment will help you understand the basics of
To develop a C program that can encrypt and decrypt text using the Caesar cipher technique. This assignment will help you understand the basics of user defined functions, C library functions, string manipulation, character encoding, and the application of simple cryptographic principles.
a Your taskProgram requirements:
InputOutput: Your program should prompt the user to enter the text to be encrypted or decrypted and the shift value. It should then display the resulting text after encryption or decryption see sample on page
Your program should provide the user with the proper instructions on the screen.
All code and functions should be documented using comments before each function
Functions:
encryptText: This function takes the plaintext and the shift value as inputs and returns the encrypted text.
decryptText: This function takes the encrypted text and the shift value as inputs and returns the decrypted text original plaintext
Error Handling: Your program should handle cases where the shift value is outside the range of to including negative numbers, and prompt the user to enter a valid shift value.
Character Handling: Ensure that the cipher only applies to alphabetical characters both uppercase and lowercase Nonalphabetical characters such as punctuation and spaces should not be altered.
Wraparound: Implement wraparound for the shift, so that if a letter shifts beyond Z it goes back to A and similarly in reverse for decryption.
Your program should automatically validate the encryption by decrypting the message right after it's encrypted, you can adjust the main function to encrypt the input text and then immediately decrypt the encrypted text using the same shift value. This way, you can directly compare the original text with the decrypted text to ensure the encryption and decryption processes are accurate.
Instructions:
Start by including the necessary header files.
You will need to include the following:
#include
#include
#include For isalpha and tolower
Implement the encryptText and decryptText functions.
Function prototypes
void encryptTextchar int;
void decryptTextchar int;
Ensure your main function handles user input, calls the appropriate functions based on the user's choice encrypt or decrypt and outputs the result. See sample code provided below.
Test your program with various inputs to ensure accuracy.
Notes on how to organize and document your program:
Note: every program you submit must include the information colored in green. The highlighted text with yellow and blue will change.
Make sure that your program file name will include your last name at the beginning or the end.
Name: your first and last name
Assignment name & number: Assignmentx
Due date: xx xx xx
Program description:
#include
#include
#include For isalpha and tolower
your function prototypes go here
int main
Your code goes here.
char text; Buffer for the text
int shift, choice;
printfChoose an option:
Encrypt
Decrypt
Option: ;
scanfd &choice;
getchar; Consume the newline character left in the input buffer
printfEnter the text: ;
fgetstext sizeoftext stdin; Read the text including spaces
textstrcspntext
; Remove the newline character
printfEnter the shift value: ;
scanfd &shift;
use if else or switch for calling the proper operation.
code for function implementation
b What to turn in:
For this assignment, you need to turn in your C program file, with at least samples of output you need to run your program at least two times with different input. You need to submit a script file that shows your work. Zip all files in one zipped file and upload your zipped file to Canvas.
Please follow the instructions from the first assignment. Every file you submit should be have a name that starts with your last eg yourlastnamefunctionshwXc For more information about editing and creating your script file, please refer to the homework instructions document from the first assignment, and the web resources section on canvas.
c Here is a sample of possible inputoutput
Choose an option:
Encrypt
Decrypt
choose to encrypt.
Enter the text: Hello, World!
Enter the shift value:
Encrypted text: Khoor, Zruog!
Decrypted text should match original: Hello, World!
Validation successful: The decrypted text matches the original text
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
