This program is for implementing Poly-Alphabetic Encryption.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,j,k=0;
char *ciper,*plan,*plan2;
clrscr();
puts("\nEnter the sender side text : ");
gets(plan);
puts("\nEnter the groups of character : ");
scanf("%d",&n);
for(i=0;plan[i]!='\0';i=i+n)
{
k++;
for(j=i;j<i+n;j++)
{
if((plan[j]>=65 && plan[j]<=90-k) || (plan[j]>=97 && plan[j]<=122-k))
ciper[j]=plan[j]+k;
else if((plan[j]>90-k && plan[j]<=90)||(plan[j]>122-k && plan[j]<=122))
ciper[j]=plan[j]-26+k;
else
ciper[j]=plan[j];
}
}
ciper[j]='\0';
puts("\nThe trasmitted data is : \n");
puts(ciper);
k=0;
for(i=0;ciper[i]!='\0';i=i+n)
{
k++;
for(j=i;j<i+n;j++)
{
if((ciper[j]>=65+k && ciper[j]<=90) || (ciper[j]>=97+k && ciper[j]<=122))
plan2[j]=ciper[j]-k;
else if((ciper[j]>=65 && ciper[j]<=65+k)||(ciper[j]>97 && ciper[j]<=97+k))
plan2[j]=ciper[j]+26-k;
else
plan2[j]=ciper[j];
}
}
plan2[j]='\0';
puts("\nThe Reciver side data is : \n");
puts(plan2);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,j,k=0;
char *ciper,*plan,*plan2;
clrscr();
puts("\nEnter the sender side text : ");
gets(plan);
puts("\nEnter the groups of character : ");
scanf("%d",&n);
for(i=0;plan[i]!='\0';i=i+n)
{
k++;
for(j=i;j<i+n;j++)
{
if((plan[j]>=65 && plan[j]<=90-k) || (plan[j]>=97 && plan[j]<=122-k))
ciper[j]=plan[j]+k;
else if((plan[j]>90-k && plan[j]<=90)||(plan[j]>122-k && plan[j]<=122))
ciper[j]=plan[j]-26+k;
else
ciper[j]=plan[j];
}
}
ciper[j]='\0';
puts("\nThe trasmitted data is : \n");
puts(ciper);
k=0;
for(i=0;ciper[i]!='\0';i=i+n)
{
k++;
for(j=i;j<i+n;j++)
{
if((ciper[j]>=65+k && ciper[j]<=90) || (ciper[j]>=97+k && ciper[j]<=122))
plan2[j]=ciper[j]-k;
else if((ciper[j]>=65 && ciper[j]<=65+k)||(ciper[j]>97 && ciper[j]<=97+k))
plan2[j]=ciper[j]+26-k;
else
plan2[j]=ciper[j];
}
}
plan2[j]='\0';
puts("\nThe Reciver side data is : \n");
puts(plan2);
getch();
}