HILL CIPHER

PROGRAM ON HILL CIPHER

Hill Cipher is one of the encryption algorithm used for encryption of  plain text , in cyber network security, so here is the code:-

#include<stdio.h>
#include<conio.h>
void main()
{
 char pt[10];
 int k[3][3],i,j,o,l,p[3][1],c[3][1],m,n,sum=0;
 clrscr();
 printf("\n enter Plaintext= ");
 gets(pt);
 printf("\n enter the values of keys in matrix=\n");
 for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
 {
  scanf("%d",&k[i][j]);
 }
 }
 for(o=0;o<3;o++)
 {
  for(l=0;l<1;l++)
  {
   pt[o]=pt[o]-97;
   p[o][l]=pt[o];
  }
 }
for(i=0;i<3;i++)
{

for(l=0;l<1;l++)
{
 for(o=0;o<3;o++)
 {sum=sum+k[i][o]*p[o][l];
 }
 c[i][l]=sum;
 sum=0;
}
}
printf("product is=\n");
for(i=0;i<3;i++)
{
 for(l=0;l<1;l++)
 {
  printf("%d",c[i][l]);
 }
 printf("\n");
}
printf("Cipher Text is= ");
for(i=0;i<3;i++)
{
for(l=0;l<1;l++)
{
 printf("%c",c[i][l]%26+97);
}
}
getch();
}

OUTPUT

HILL CIPHER HILL CIPHER Reviewed by Unknown on 18:32 Rating: 5

No comments:

Powered by Blogger.