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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!