main.cpp
//fn to generate the encrypted text for playfair cipher

fn to generate the encrypted text for playfair cipher
fn to generate the encrypted text for playfair cipher
void playfair ::processplay()
{
    int i;
    for (i = 0; i < strlen(plaintext_playfair); i += 2)
    {
        char a = plaintext_playfair[i], b = plaintext_playfair[i + 1];
        int j, ai, aj, bi, bj;
        for (j = 0; j < 5; j++)
        {
            int k;
            for (k = 0; k < 5; k++)
            {
                if (grid[k][j] == a)
                {
                    ai = j;
                    aj = k;
                }
                else if (grid[k][j] == b)
                {
                    bi = j;
                    bj = k;
                }
            }
        }
        if (ai == bi)
        { 
            ciphertext_playfair[i] = grid[ai][(aj + 1) % 5];
            ciphertext_playfair[i + 1] = grid[bi][(bj + 1) % 5];
        }
        else if (aj == bj)
        { 
            ciphertext_playfair[i] = grid[(ai + 1) % 5][aj];
            ciphertext_playfair[i + 1] = grid[(bi + 1) % 5][bj];
        }
        else
        { 
            ciphertext_playfair[i] = grid[ai][bj];
            ciphertext_playfair[i + 1] = grid[bi][aj];
        }
    }
    ciphertext_playfair[strlen(plaintext_playfair)] = '\0';
}
void playfair :: processplay ( ) { int i ; for ( i = 0 ; i < strlen ( plaintext_playfair ) ; i += 2 ) { char a = plaintext_playfair [ i ] , b = plaintext_playfair [ i + 1 ] ; int j , ai , aj , bi , bj ; for ( j = 0 ; j < 5 ; j ++ ) { int k ; for ( k = 0 ; k < 5 ; k ++ ) { if ( grid [ k ] [ j ] == a ) { ai = j ; aj = k ; } else if ( grid [ k ] [ j ] == b ) { bi = j ; bj = k ; } } } if ( ai == bi ) { ciphertext_playfair [ i ] = grid [ ai ] [ ( aj + 1 ) % 5 ] ; ciphertext_playfair [ i + 1 ] = grid [ bi ] [ ( bj + 1 ) % 5 ] ; } else if ( aj == bj ) { ciphertext_playfair [ i ] = grid [ ( ai + 1 ) % 5 ] [ aj ] ; ciphertext_playfair [ i + 1 ] = grid [ ( bi + 1 ) % 5 ] [ bj ] ; } else { ciphertext_playfair [ i ] = grid [ ai ] [ bj ] ; ciphertext_playfair [ i + 1 ] = grid [ bi ] [ aj ] ; } } ciphertext_playfair [ strlen ( plaintext_playfair ) ] = ' \0 ' ; }
fn to generate the encrypted text for playfair cipher
fn to generate the encrypted text for playfair cipher
//Find indices of a and b
 //Process each digram and write into ciphertext_playfair
 //Case 1 : Same row
 //Case 2 : Same column
 //Case 3 : rectangle
