CEASAR
CEASAR
2. Language used.
The implementation is done using the C language, C is a Object Oriented Programing
language that was developed in the early 1970s by Dennis Ritchie at Bell Labs. It is
one of the most widely used programming languages.
3. Procedures followed.
Step one: Including necessary header files ,These lines include the necessary header
files. <stdio.h> is included for standard input/output operations, and <string.h> is
included for string manipulation functions.
Step two: Implementing Caesar Cipher Encryption and Decryption Functions , These
functions define the logic for encrypting and decrypting a message using the Caesar
cipher algorithm. The encrypt function shifts each letter in the message by a specified
amount, and the decrypt function reverses the process.
Step three: Implementing the Main Function ,This part of the code takes user input
for the message, key value, and the choice of encryption or decryption. It then calls
the appropriate function based on the user's choice and displays the result.
Step four: Compiling and Running, Compiling the code using a C compiler (e.g.,
gcc) and run the executable to test the Caesar cipher encryption and decryption
functionality.
4. Results
After running the code the user is prompted to enter the text , key value and either
encrypt the plain text or decrypt the cipher text.
Enter a message: box
Enter the key value: 3
Choose an option:
1. Encrypt
2. Decrypt
1
Encrypted message: ERA
Code Snippet:
#include <stdio.h>
#include <string.h>
int main() {
// Declare variables to store user input
char message[100];
int shift, choice;
return 0;
}
6. Algorithims Used.
The program works under two(2) alogorithims , which are:
a. Encryption Algorithm:
b. Decryption Algorithim:
Similar to encryption, for each character in the message, the program checks
whether it is an uppercase or lowercase letter.
If it is an uppercase letter, it shifts it back by subtracting the shift value (shift)
and adding 26 (the alphabet length) to handle wrapping around. The character
is then converted back to uppercase.
If it is a lowercase letter, the same process is applied, but the character is
converted back to lowercase.
Non-alphabetic characters are left unchanged.
7. Conclusion.
The objective of the provided C code was to implement a basic form of the Caesar
cipher, allowing users to encrypt and decrypt messages using a specified key value.
The program achieves this objective, and it provides a simple command-line interface
for users to interact with the encryption and decryption functionalities.