main.cpp
//fn to generate the 5x5 grid for the playfair cipher

fn to generate the 5x5 grid for the playfair cipher
fn to generate the 5x5 grid for the playfair cipher
void playfair ::generate_grid()
{
    int i, k = 0; 
    for (i = 0; i < strlen(key); i++)
        grid[i / 5][i % 5] = key[i];
    char temp[26];
    int o = 0; 
    for (i = 0; i < 26; i++)
    {
        int j, repeat = 0;
        for (j = 0; j < strlen(key); j++)
            if (alpha2[k] == key[j])
                repeat++;
        if (repeat || alpha2[k] == 'j')
        {
            k++;
            continue;
        }
        temp[o++] = alpha2[k++];
    }
    temp[o] = '\0';
    o = 0;
    for (i = strlen(key); i < 26; i++)
    {
        grid[i / 5][i % 5] = temp[o++];
    }
}
void playfair :: generate_grid ( ) { int i , k = 0 ; for ( i = 0 ; i < strlen ( key ) ; i ++ ) grid [ i / 5 ] [ i % 5 ] = key [ i ] ; char temp [ 26 ] ; int o = 0 ; for ( i = 0 ; i < 26 ; i ++ ) { int j , repeat = 0 ; for ( j = 0 ; j < strlen ( key ) ; j ++ ) if ( alpha2 [ k ] == key [ j ] ) repeat ++ ; if ( repeat || alpha2 [ k ] == ' ' ) { k ++ ; continue ; } temp [ o ++ ] = alpha2 [ k ++ ] ; } temp [ o ] = ' \0 ' ; o = 0 ; for ( i = strlen ( key ) ; i < 26 ; i ++ ) { grid [ i / 5 ] [ i % 5 ] = temp [ o ++ ] ; } }
fn to generate the 5x5 grid for the playfair cipher
fn to generate the 5x5 grid for the playfair cipher
//k iterates through the alphabet
 //to input key into grid
 //to find the alphabets not part of the key
 //o iterates through temp
 //alpha2 is the alphabet in lower case - preprocessor declared at the head of the program
 //to fill the rest of the grid with the remainder alphabets
