Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ShiftText.h"
- #include "SubstitutionText.h"
- #include "Shift3Text.h"
- #include "DecryptException.h"
- #include <iostream>
- #define SHIFTING_KEY 10
- #define DICTIONARY_PATH "dictionary.csv"
- using namespace std;
- void Alice();
- PlainText Bob(SubstitutionText msg);
- PlainText Bob(ShiftText msg);
- PlainText Bob(Shift3Text msg);
- /*
- This is the main function of the program.
- It starts the conversation between Alice and Bob
- */
- int main()
- {
- Alice();
- /*
- ShiftText* temp = new ShiftText("hello", 3);
- cout << temp->getText();
- temp->decrypt(3);
- cout << temp->getText();
- */
- cout << endl;
- system("PAUSE");
- return 0;
- }
- /*
- This is Alice's part in the conversation.
- It gets a legal string from the user ans sends it to Bob in
- three different kinds of encryptions.
- It also prints every response from Bob.
- */
- void Alice()
- {
- fstream myFile;
- cout << "Alice:" << endl;
- cout << "Enter a message to send to Bob:" << endl;
- cout << "Smile bob, its a printscreen." << endl;
- cout << endl;
- ShiftText *msg1 = new ShiftText("Smile bob, its a printscreen." ,4);
- Shift3Text *msg2 = new Shift3Text("Smile bob, its a printscreen.");
- SubstitutionText *msg3 = new SubstitutionText("Smile bob, its a printscreen.", myFile);
- std::cout << "Sending in substitution mode..." << std::endl;
- cout << endl;
- cout << Bob(*msg3).getText() << endl;
- std::cout << "Sending in shift mode..." << std::endl;
- cout << endl;
- std::cout << Bob(*msg1).getText() << endl;
- std::cout << "Sending in shift-3 mode..." << std::endl;
- cout << endl;
- cout << Bob(*msg2).getText() << endl;
- }
- /*
- This function handles Bob's part of the conversation
- when he receives a message encrypted in Substitution mode
- */
- PlainText Bob(SubstitutionText msg)
- {
- cout << "Bob:" << endl;
- std::cout << "The received massege: ";
- std::cout << msg.getText() << std::endl;
- fstream myFile;
- msg.decrypt(myFile);
- std::cout << "The decrypted massege: ";
- std::cout << msg.getText() << std::endl;
- return PlainText("Thank you Alice!");
- }
- /*
- This function handles Bob's part of the conversation
- when he receives a message encrypted in Shift mode
- */
- PlainText Bob(ShiftText msg)
- {
- cout << "Bob:" << endl;
- std::cout << "The received massege: ";
- std::cout << msg.getText() << std::endl;
- fstream myFile;
- msg.decrypt(4);
- std::cout << "The decrypted massege: ";
- std::cout << msg.getText() << std::endl;
- return PlainText("Thank you again Alice!");
- }
- /*
- This function handles Bob's part of the conversation
- when he receives a message encrypted in Shift-3 mode
- */
- PlainText Bob(Shift3Text msg)
- {
- cout << "Bob:" << endl;
- std::cout << "The received massege: ";
- std::cout << msg.getText() << std::endl;
- fstream myFile;
- msg.decrypt(3);
- std::cout << "The decrypted massege: ";
- std::cout << msg.getText() << std::endl;
- return PlainText("Many Thanks Alice!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement