Cipher.: Program 1: Write A Program To Implement Ceaser
Cipher.: Program 1: Write A Program To Implement Ceaser
CIPHER.
#include <stdio.h>
int main()
{
char ch, x;
char text[100];
int i, key, flag=0;
do{
printf("To encrypt, input e or E\n\n");
printf("To decrypt, input d or D\n\n");
printf("To exit, input any other letter\n\n");
printf("Your choice ->");
scanf("%c", &ch);
if(ch == 'e' || ch == 'E'){
printf("Input text to encrypt -> ");
scanf("%s", text);
printf("Enter key: ");
scanf("%d", &key);
for(i=0; text[i]!='\0'; i++){
x = text[i];
x = text[i] -32 + key;
if(x>90){
x -= 26;
}
text[i] = x;
printf("%c", text[i]);
}
printf("\n");
}
OUTPUTS: