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.
kindly reply
http://www.umich.edu/~umich/fm-34-40-2/ch7.pdf(pg:7-12 onwards)
http://en.wikipedia.org/wiki/Playfair_cipher#Cryptanalysis

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#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"
    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;
}
Last edited on
Topic archived. No new replies allowed.