Amar Shah
my program hill cipher encryption side

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j,k[3][3],p[3][1],c[3][1],b,m,s=0;
char plain[3];
clrscr();

puts("Enter the plain text";
gets(plain);

puts("Enter the key matrix";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&k[i][j]);
}
}

for(i=0;plain[i]!='\0';i++)
{
m=plain[i];
if(m>=123)
{
m=m-26;
}
m=m-97;
p[i][0]=m;
}

for(i=0;i<3;i++)
{
b=0;
s=0;
for(j=0;j<3;j++)
{
s=s+(k[i][b]*p[b][0]);
b++;
}
c[i][0]=s;

}

puts("Encryption:--\n";
for(i=0;i<3;i++)
{
printf("%d\n",c[i][0]);
}

getch();
}

add to the decryption side
Like · Comment ·
Amar Shah and 2 other like this
Download Android App