well it is not really the actual thing. Anyway, im using digital mars.
Code:
#include <iostream>
#include <string>
#include <vector>
#include "tool.h"
using namespace std;
Key::Key(char choice) {
cout << "Enter the key.";
getinfo(choice);
}
void Key::getinfo(char choice) {
switch(choice) {
case '1':
cin >> value;cout << value;
break;
}
}
Cipher::Cipher() {
cout << "Enter the encrypted-text.";
cin >> Text;
length = Text.length();
}
int main() {
Menu();
return 0;
}
void Menu(void) {
char choice; // What to do
// starting the menu
cout << "Menu:" << endl;
cout << " 1. Sort the cipher text into shrift siphers according to the key length" << endl;
cout << " 2. Frequency analysis the cipher-text." << endl;
cout << " 3. Decrypt a monoalpheric cipher with a key." << endl;
cout << "Enter q to quit.\n" << endl;
cout << "Enter your choice: ";
cin >> choice;
switch(choice) {
case '1' :
SplitCode(choice);
Menu();
break;
case '2' :
Menu();
break;
case '3' :
Menu();
break;
case 'q' :
break;
default :
cout << "Please enter a valid choice." << endl;
Menu();
break;
}
}
void SplitCode(char choice) {
Cipher Vigenerec; // Create an instance of the cipher object
Key Vigenerek(choice); // Create an instance of the key
int Rmd = Vigenerek.value % Vigenerec.length;// The number of odd digits out (uncompleted bits of key)
int ArrayLen = (Vigenerec.length - Rmd) / Vigenerek.value;
if(Rmd) ArrayLen++;
vector<char> Split_Text[20];
for(i=0;i<Vigenerek.value;++i) Split_Text[i].resize(ArrayLen);
for(i=0;i<Vigenerec.length;++i) {
int r = i % 5; // The bit of the key
int r2 = (i-r)/5; // How many times did the key looped
Split_Text[r][r2] = Vigenerec.Text[i];
}
for(i=0;i<Vigenerek.value;++i) {
for(i1=0;i1<ArrayLen;i++) cout << Split_Text[i][i1];
cout << "" << endl;
}
}
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// ///////////////variable declare
int i, i1; // Loop variables
// ///////////////library functions declaration
char * strcat ( char*, char const* );
// ///////////////class or structures
class Key {
public:
int value; // The actual key for shrift keys
string code; // The key for other monoalpheric ciphers
int length; // The length of the key
char Shrift_Key[2][26]; // The entire key for a shrift cipher
Key(char choice); // Constructor
void getinfo(char choice);
};
class Cipher {
public:
int length; // Length of array
string Text;
Cipher(); // Constructor
};
// /////////////////functions protype
void SplitCode(char choice);
void Menu(void);
it is actually that.