This blog is about
implementation of Caesar cipher algorithm in c.
Hope that this will help to understand the concept of Caesar cipher algorithm.
For any query regarding c/c++ concept please contact me at
khimanichirag@gmail.com
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<graphics.h>
void main()
{
int key,i;
char data[30];
clrscr();
printf("\nEnter the plain text: ");
gets(data);
printf("\nEnter the key value: ");
scanf("%d",&key);
for(i=0;i<strlen(data);i++)
{
if(data[i]!=' ')
{
if(data[i]>= data[strlen(data)-1-key])
{
data[i]=data[i]-26;
}
data[i]=data[i]+key;
}
}
printf("Your cipher text is: %s",data);
getch();
}
No comments:
Post a Comment