Background: One of the earliest and simplest forms of encrypting messages is called the Caesar cipher. It is named after Julius Caesar who used a simple substitution technique when sending private correspondence of military significance. The implementation of this technique is fairly simple. If the user provides a key of 2, all letters are shifted down the alphabet by 2, so that A becomes C, D becomes F, and so forth.
Learning Objectives: This assignment connects to the following course goal.
Course Goal #5: Improve problem-solving and programming competency by building ever complex programs, specifically through analyzing, designing, implementing, testing and debugging C programs using various data types, loops, branches, arrays, and structs.
Assignment Requirements:
Implement a Caesar Cipher in C
Your program should take a single command line argument that defines the key
Your code should read an unencrypted message from the user and write the encrypted message to the screen
A single command line argument will define the key. Defining how many positions the letter should be shifted
You can assume that all messages are uppercase and you will not be given lowercase letters, punctuation or special characters (except space characters).
Space characters should be output without substitution. Just print them verbatim.
How Should Your Caesar Cipher Work?
Inputs / Outputs:
Your program should take in 2 command line arguments. The first argument is the substitution key that determines of shift. A shift of two will advance all letters by two in alphabetical order, such that A becomes C, G becomes I, etc. The second command line argument should set to either e or d. The value e stands for encrypt and d stands for decrypt. see image.
If you selected the encryption mode, the program asks you to input the message to encrypt. The encrypted message is shown at the bottom. see image.
If we set d for decryption mode the program will take the encrypted text and convert it back to the original message. Notice that the substitution key must be identical to successfully decrypt the message. see image.
TEST CASES: You can use these test cases to determine whether or not your code works correctly
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.