0% found this document useful (0 votes)
24 views4 pages

Caser Cipher Encyption Algorithm

The document contains C code for a Caesar Cipher encryption and decryption algorithm. The encryption process shifts characters based on a provided key, while the decryption reverses this process. Both algorithms handle uppercase and lowercase letters, ignoring spaces.

Uploaded by

pratham.prydan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views4 pages

Caser Cipher Encyption Algorithm

The document contains C code for a Caesar Cipher encryption and decryption algorithm. The encryption process shifts characters based on a provided key, while the decryption reverses this process. Both algorithms handle uppercase and lowercase letters, ignoring spaces.

Uploaded by

pratham.prydan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

ENS EN.

NO:206400316171

Caser Cipher Encryption Algorithm


#include<stdio.h>

#include<conio.h>

int main()

char str[100];

int i,key;

printf("Enter the Message to Encrption: ");

gets(str);

printf("Enter the key: ");

scanf("%d",&key);

for(i=0;str[i];i++)

if(str[i]==' ')

continue;

else if(str[i]>='a' && str[i]<='z')

if(str[i]+key > 'z')

str[i]=str[i]+key-26;

else

str[i]=str[i]+key;

else if(str[i]>='A' && str[i]<='Z')

if(str[i]+key > 'Z')

str[i]=str[i]+key-26;

else

str[i]=str[i]+key;

printf("The Encrypted Message is: ");

puts(str);

}
ENS EN.NO:206400316171

Output:
ENS EN.NO:206400316171

Caser Cipher Decryption Algorithm


#include<stdio.h>

int main()

char message[100], ch;

int i, key;

printf("Enter a message to decrypt: ");

gets(message);

printf("Enter key: ");

scanf("%d", &key);

for(i = 0; message[i] != '\0'; ++i)

ch = message[i];

if(ch >= 'a' && ch <= 'z')

ch = ch - key;

if(ch < 'a'){

ch = ch + 'z' - 'a' + 1;

message[i] = ch;

else if(ch >= 'A' && ch <= 'Z')

ch = ch - key;

if(ch < 'A'){

ch = ch + 'Z' - 'A' + 1;

message[i] = ch;

printf("Decrypted message: %s", message);

return 0;

}
ENS EN.NO:206400316171

You might also like