This simple program written in C, with the purpose to encrypt and decrypt text messages using the Caesar Cipher.
Invented by Julius Caesar, this encryption technique substitutes each letter of a plain text into another letter of the alphabet. The latter is determined by the key provided. Assuming each letter of the latin alphabet is tied to an incrementing number (eg. A --> 0, B --> 1, C --> 2 etc.), the ciphered letter will be changed to the one that has a corresponding number of initial + key number. When ciphering, this shift will be on the right (initial + key). When deciphering, it will shift left (initial - key). This was implemented by adding or abstracting the key number to the ASCII values of each letter. Works only on english alphabet. A decipher is succeeded also when key = provided_key % 26. The generated text is Case-Sensitive.
The word Bark needs to be ciphered. Assuming the key is set to eg. 16, the generated word is : B --> (1 + 16) % 26 = 17 --> R, a --> (0 + 16) % 26 = 16 --> q, r --> (17 + 16) % 26 = 7 --> h, k --> (10 + 16) % 26 = 0 --> a. Result = Rqha.
Type encrypt or decrypt to declare function. Enter text to encrypt/decrypt. Enter key.