http://en.wikipedia.org/wiki/Transposition_cipher#Columnar_transposition
This is wiki site of what am trying to do
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
char GRID[3][80];
int MENU(int menu_choice);
int REVIEW_OF_GRIDS_FIRST_79_CHARACTERS(int four);
int main()
{
cout << " This is RAIL FENCE CIPHER\n" << endl;
//-----------------------------------------------------------------------------------------------------
//filing GRID with asterisks(*)
char asterisk='*';
int k=-1;
int i=0;
while(k<2)
{
k++;
while(i<80)
{
GRID[k][i] = asterisk;
i++;
}
cout << "\n" ;
i=0;
}
//-----------------------------------------------------------------------------------------------------
//plaintext input into GRID
char plaintext[0];
cout << "Enter message to encode:" << " NOTE:Asterisk(*) symbol is not allowed\n";
cin >> plaintext;
int grid_row[5] = {0,1,2,1,99}; //012101210121 is pattern and 99 is irrelevant
int row_counter = 0;
int grid_position_X = 0;
for(int plaintext_counter = 0; plaintext_counter < strlen(plaintext); plaintext_counter++)
{
if(row_counter == 4)
{
row_counter = 0;
}
GRID[grid_row[row_counter]][grid_position_X] = plaintext[plaintext_counter];
row_counter++;
grid_position_X++;
}
//-----------------------------------------------------------------------------------------------------
//user choice
int user_choice = 0;
while(user_choice != 6 || user_choice != 7) //restarting and ending program still not finished
{
user_choice=MENU(0);
switch(user_choice)
{
case 1:
{
//not finished
}
case 2:
{
//not finished
}
case 3:
{
cout << "There are " << strlen(plaintext) << " characters" <<endl<<endl;//shows always 2
break;
}
case 4: //it doesnt show more than 5 chars
{
REVIEW_OF_GRIDS_FIRST_79_CHARACTERS(0);
break;
}
case 5:
{
//not finished
}
}
}
cin.get();
return 0;
}
int MENU(int menu_choice)
{
cout << "Enter number of operation you would like to preform\n";
cout << "1.Output encoded characters on screen\n";
cout << "2.Save encoded characters to text file\n";
cout << "3.Display length of characters\n";
cout << "4.Review grids first 79 characters\n";
cout << "5.\n"; //haven't decided what to put here yet
cout << "6.Run program again\n";
cout << "7.Exit program\n";
cin >> menu_choice;
return menu_choice;
}
int REVIEW_OF_GRIDS_FIRST_79_CHARACTERS(int four) //int four is unimportant
{
int k2=-1;
int i2=0;
while(k2<2)
{
k2++;
while(i2<80)
{
cout << GRID[k2][i2] ;
i2++;
}
cout << "\n" ;
i2=0;
}
}
PROBLEMS are that it doesn't show more than 5 chars on choice 4 and on choice 3 it shows always 2