Question
Write a c program to encrypt and decrypt a string using Caesar Cipher method Main program Input will be a string and a key. Call
Write a c program to encrypt and decrypt a string using Caesar Cipher method
Main program
Input will be a string and a key.
Call encrypt function and pass the required parameters
Call decrypt function and pass the required parameters.
Encrypt Function
Use for loop to take the characters one by one until the end of the string.
Check if the letter is uppercase, If it is true, use x=(x-'A' + key) % 26 +'A'
Else use x=(x-'a' + key) % 26 +'a'
Decrypt Function
Use for loop to take the characters one by one until the end of the string.
Check if the letter is uppercase, If it is true, use x=(x-'A' - key) % 26 +'A'
Else use x=(x-'a' - key) % 26 +'a'
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started