-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvigenere.cpp
48 lines (38 loc) · 1.04 KB
/
vigenere.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include "functions.h"
using namespace std;
int main()
{
testFunctions();
start:
string inputMessage; //message we want to encrypt/decrypt
string key; //the "key" we will encrypt/decrypt with, based on the vigenere cipher
int mode;
cout << "Run VigenereC in encryption mode [1] or decryption mode [2]?: ";
cin >> mode;
cin.ignore();
cout << "Enter the MESSAGE text for encryption/decryption: ";
getline(cin, inputMessage);
cout << "Enter the KEY text: ";
getline(cin, key);
if (mode == 1)
{
string output = vigenereEncrypt(inputMessage, key);
cout << "Encrypted text: " << output << endl;
}
else
{
string output = vigenereDecrypt(inputMessage, key);
cout << "Decrypted text: " << output << endl;
}
char response;
cout << "Enter [R] to restart or any other key to exit: ";
cin >> response;
cin.ignore();
if (response == 'R' || response == 'r')
{
goto start;
} else {
return 0;
}
}