Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 25. In cryptography, a Caesar cipher is one of the simplest and most wid

ID: 3759499 • Letter: P

Question

Problem 25. In cryptography, a Caesar cipher is one of the simplest and most widely known encryption techniques. It is named after Julius Caesar, who is believed to use it to encrypt messages of Military significance. The Caesar cipher replaces each letter with a letter three positions before it in the alphabet: letter Z is replaced with letter W, letter Y is replaced with letter V, letter X is replaced with letter U, etc. The cipher loops back in the beginning of the alphabet: letter C is replaced with letter Z, letter B is replaced with letter Y. and letter A is replaced with letter X. Write a program that takes a single word and encrypts it using Caesar cipher. To keep things simple, you can assume that all letters in the word ate capital: Enter a word: DOG The encrypted word is: ALD Problem 26. Write a program that decrypts Caesar cipher: Enter encrypted word: ALD The original word is: DOG

Explanation / Answer

#include<stdio.h>
int main()
int crypt;
int x,y;
int key;
char input;
{
printf("Do you want your characters encrypted [1] or decrypted [2]? ");
scanf("%d", crypt);
printf("Enter a key");
scanf("%d", key);
while((x=getchar())!=EOF && crypt=1)
{
printf("Enter data to encrypt. ");
fflush(stdin);
gets(input);
if(x >='A' && x <='Z')
{
if((y = x + key) <= 'Z')
putchar(y);
else
{
y = x - key;
putchar(y);
}
}
else if(x >='a' && x <='z')
{
if((y= x + key) <= 'z')
putchar(y);
else
{
y = x - key;
putchar(y);
}
}
else
putchar(x);
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote