# Playfair matrix retreiving

• 11-09-2012
ankurkhanna145
Playfair matrix retreiving
hello everyone,
i am making a programme on the playfair matrix in which both cipher text and plain text is given to me and im ought to retrieve the KEYWORD.
i m stuck at a point where im suppose to start entering the elements in the 5*5 matrix because when i got a starting point,i m not getting it how/where to place it in the matrix since each pair can be placed according to 3 rules(ERDL,ECDL,RECTANGULARLY) and every initial entry can be placed in 25 ways.
http://www.umich.edu/~umich/fm-34-40-2/ch7.pdf(pg:7-12 onwards)
Playfair cipher - Wikipedia, the free encyclopedia
• 11-09-2012
C_ntua
I think you should post some code, what basically you tried so far. Then people can help on that. Otherwise you would need people to actually go and read all those PDF pages to even understand the issue which is not that efficient
• 11-10-2012
ankurkhanna145
this is what i have done so far.
stuck at a point where im suppose input the array at random places.

Code:

```#include<iostream> #include<conio.h> #include<stdio.h> #include<cmath> using namespace std; int main() {     char p[300],c[300],a[25][26];     int n,l,l2;     cout<<"ENTER THE PLAIN TEXT : \n"; /*what should be the procedure to eradicate special character case,     if any.(by comparing ASCII codes but how??)*/     for(int i=0;i<300;i++)     {         cin>>p[i];         if(p[i]=='.')         {             l=i;           break;         }     }     cout<<"\n\nENTER THE CIPHER TEXT : \n";     for(int k=0;k<300;k++)     {         cin>>c[k];         if(c[k]=='.')         {             if(k%2!=0)             {                 cout<<"\n\nINVALID CIPHER TEXT(CANNOT PAIR IN DIAGRAPHS) ";//How to exit from the program??.             }             else             {                 break;             }         }     }     l2=l;     for(int i=0;i<l2;i++)     {         if(i%2!=0)         {             if(p[i-1]==p[i])             {                 p[i]='x';                 for(int j=l2;j>=i+1;j--)                 {                     p[j+1]=p[j];                 }                 l2++;                 p[i+1]=p[i-1];             }         }         else         {             continue;         }     }     cout<<endl<<endl;     for(int i=0;i<l2;i++)     {         if(i%2!=0)         {         cout<<p[i]<<" ";         }         else if(i==(l2-1)&&i%2==0)         {             cout<<p[i]<<'x';         }         else         {             cout<<p[i];         }     }     cout<<"\n\n";             //DECRYPTING     for(int i=0;i<l2;i++)     {         if(i%2!=0)         {             if(p[i-1]==c[i])             {                         }         }     }     return 0; }```