#include<stdio.h>
int main()
{
char mes[100] = "CEASER", chr;
int x, key = "HJFXJW";
printf("CEASER to be encrypted\n");
printf("The key is: HJFXJW\n ");
for(x = 0; mes[x] != '\0'; ++x){
chr = mes[x];
if(chr >= 'a' && chr <= 'z'){
chr = chr + key;
if(chr > 'z'){
chr = chr - 'z' + 'a' - 1;
}
mes[x] = chr;
}
else if(chr >= 'A' && chr <= 'Z'){
chr = chr + key;
if(chr > 'Z'){
chr = chr - 'Z' + 'A' - 1;
}
mes[x] = chr;
}
}
printf("Encrypted message: %s", mes);
return 0;
}
Comments
Leave a comment