Write a Program For Mono-Alphabetic Substitution.
#include<stdio.h>
#include<conio.h>
void main()
{
char str[50],str2[50],str1[50],ch;
int i,j=0,res,n;
clrscr();
printf("\nEnter data: ");
gets(str);
printf("\nEnter Key value: ");
scanf("%d",&n);
i=0;
while(str[i]!='\0')
{
res=str[i]+n;
str1[j++]=res;
i++;
}
str1[j]='\0';
printf("\nEncrypted Data is %s",str1);
i=0,j=0;
while(str1[i]!='\0')
{
res=str1[i]-n;
str2[j++]=res;
i++;
}
str2[j]='\0';
printf("\nDecryped Data is %s",str2);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
char str[50],str2[50],str1[50],ch;
int i,j=0,res,n;
clrscr();
printf("\nEnter data: ");
gets(str);
printf("\nEnter Key value: ");
scanf("%d",&n);
i=0;
while(str[i]!='\0')
{
res=str[i]+n;
str1[j++]=res;
i++;
}
str1[j]='\0';
printf("\nEncrypted Data is %s",str1);
i=0,j=0;
while(str1[i]!='\0')
{
res=str1[i]-n;
str2[j++]=res;
i++;
}
str2[j]='\0';
printf("\nDecryped Data is %s",str2);
getch();
}
No comments:
Post a Comment