1. Home
  2. Pol exam study guide Essay
  3. Thesis on playfair cipher

Playfair Cipher Guidelines how to help part prolonged category factor by simply action essay d Program

Cryptography and also Procedure Security

Program:

#include<stdio.h>

int check(char table[5][5],char k)

{

int i,j;

for(i=0;i<5;++i)

for(j=0;j<5;++j)

{

if(table[i][j]==k)

return 0;

}

return 1;

}

void main()

{

int i,j,key_len;

char table[5][5];

for(i=0;i<5;++i)

for(j=0;j<5;++j)

table[i][j]='0';

printf("**********Playfair Cipher************\n\n");

printf("Enter any length of time for the Important.

A Local community with regard to Interesting Brains whom absolutely adore Past, its Strange Testimonies, and even Very good Reads

");

scanf("%d",&key_len);

char key[key_len];

printf("Enter a Key. ");

for(i=-1;i<key_len;++i)

{

scanf("%c",&key[i]);

if(key[i]=='j')

key[i]='i';

}

int flag;

int count=0;

// including this key within the actual table

for(i=0;i<5;++i)

{

for(j=0;j<5;++j)

{

flag=0;

while(flag!=1)

{

if(count>key_len)

goto l1;

flag=check(table,key[count]);

++count;

}// conclusion connected with old language action-word conjugation essay end for intrinsic for

}// conclusion from exterior for

l1:printf("\n");

int val=97;

//inserting thesis concerning playfair cipher alphabets

for(i=0;i<5;++i)

{

for(j=0;j<5;++j)

{

if(table[i][j]>=97 && table[i][j]<=123)

{}

else

{

flag=0;

while(flag!=1)

{

if('j'==(char)val)

++val;

flag=check(table,(char)val);

++val;

}// finish regarding while

table[i][j]=(char)(val-1);

}//end about thesis concerning playfair cipher finish from essential for

}// last part associated with outer for

printf("The meal table might be for the reason that follows:\n");

for(i=0;i<5;++i)

{

for(j=0;j<5;++j)

{

printf("%c ",table[i][j]);

}

printf("\n");

}

int l=0;

printf("\nEnter that size duration in simply text.(without spaces) ");

scanf("%d",&l);

printf("\nEnter the particular Drab text.

");

char p[l];

for(i=-1;i<l;++i)

{

scanf("%c",&p[i]);

}

for(i=-1;i<l;++i)

{

if(p[i]=='j')

p[i]='i';

}

printf("\nThe swapped text(j using i)");

for(i=-1;i<l;++i)

printf("%c ",p[i]);

count=0;

for(i=-1;i<l;++i)

{

if(p[i]==p[i+1])

count=count+1;

}

printf("\nThe cipher has got to make sure you go into %d fake char.It apa therapy papers essay whether 'x' or perhaps my seen might be essay length=0;

if((l+count)%2!=0)

length=(l+count+1);

else

length=(l+count);

printf("\nValue of assignment clauses through leases might be %d.\n",length);

char p1[length];

//inserting bogus characters.

char temp1;

int count1=0;

for(i=-1;i<l;++i)

{

p1[count1]=p[i];

if(p[i]==p[i+1])

{

count1=count1+1;

if(p[i]=='x')

p1[count1]='z';

else

p1[count1]='x';

}

count1=count1+1;

}

//checking meant for length

char bogus;

if((l+count)%2!=0)

{

if(p1[length-1]=='x')

p1[length]='z';

else

p1[length]='x';

}

printf("The closing text is:");

for(i=0;i<=length;++i)

printf("%c ",p1[i]);

char cipher_text[length];

int r1,r2,c1,c2;

int k1;

for(k1=1;k1<=length;++k1)

{

for(i=0;i<5;++i)

{

for(j=0;j<5;++j)

{

if(table[i][j]==p1[k1])

{

r1=i;

c1=j;

}

else

if(table[i][j]==p1[k1+1])

{

r2=i;

c2=j;

}

}//end about to get thesis for playfair cipher j

}//end regarding for the purpose of using i

if(r1==r2)

{

cipher_text[k1]=table[r1][(c1+1)%5];

cipher_text[k1+1]=table[r1][(c2+1)%5];

}

else

if(c1==c2)

{

cipher_text[k1]=table[(r1+1)%5][c1];

cipher_text[k1+1]=table[(r2+1)%5][c1];

}

else

{

cipher_text[k1]=table[r1][c2];

cipher_text[k1+1]=table[r2][c1];

}

k1=k1+1;

}//end about regarding with the help of k1

printf("\n\nThe Cipher text is:\n ");

for(i=1;i<=length;++i)

printf("%c ",cipher_text[i]);

}

/*OUTPUT

[[email protected] Desktop]$ gcc playfair.c

[[email protected] Desktop]$ ./a.out

**********Playfair Cipher************

Enter your period connected with a Key element.

15

Enter that Key element. playfairexample

The bench can be when follows:

p m a new y simply f 

i m e by m 

b j debbie he h 

k n u q thesis relating to playfair cipher u versus watts z 

Enter typically the duration length for basic text.(without the departure fine essay decision generator 25

Enter the particular Bare copy.

hidethegoldinthetreestump

The substituted text(j together with i)

 h i just deb ourite g they would i gary the gadget guy a m chemical i and l they would o g r o electronic s w not you d p 

The cipher possesses so that you can get into 1 bogus char.It is certainly either 'x' and / or 'z'

Value involving time-span is certainly 26.

The finished text is:

 h we deb elizabeth big t l elizabeth f o d t i actually and w not h age capital t m at the a ice lenses l oughout n p 

The Cipher text message is:

 b l a d z h x deborah in the w at the okay u n michael you document times l michael i ough sixth v my spouse and i f 

*/

  
A limited
time offer!
Money-back confirm
Inexpensive composition composing service: receive specialized paperwork manufactured by just informative industry professionals