The Autokey Cipher is a variation of the Vigenere Cipher in which the message is
ID: 3679578 • Letter: T
Question
The Autokey Cipher is a variation of the Vigenere Cipher in which the message is incorporated into the Keyword. For example, if the plain text is “THE QUICK BROWN FOX” and the keyword is “SECRET” the keyword used will be “SECRETTHEQUICKBROWNFOX”. Write a C program that will accept cipher text as input. Your intelligence agents have assured you that it is encrypted using the Autokey Cipher with a keyword “ZIPPY”. The entire message is in upper case letters only. Your program must recover the encrypted message and printout the plain text.
Explanation / Answer
#include #include #define MAXSIZE 1024 void encrypt(char*); void decrypt(char*); int menu(); int main(void) { char c, choice[2], s[MAXSIZE]; while(1) { menu(); gets(choice); if((choice[0]=='e')||(choice[0]=='E')) { puts("Input text to encrypt->"); gets(s); encrypt(s); } else if((choice[0]=='d')||(choice[0]=='D')) { puts("Input text to decrypt->"); gets(s); decrypt(s); } else break; } return 0; } void encrypt(char*str) { int n=0; char *p=str, q[MAXSIZE]; while(*p) { if(islower(*p)) { if((*p>='a')&&(*p='D')&&(*pRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.