-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
60 lines (50 loc) · 1.15 KB
/
main.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
49
50
51
52
53
54
55
56
57
58
59
60
// Mark Watson
// CS 306
// Semester Project
#include <iostream>
#include <fstream>
#include <string>
#include "encryptjpeg.h"
#include "aesencrypt.h"
using namespace std;
int main(int argc, char *argv[])
{
// validate command line arguments
if (argc != 4 || (argv[1][1] != 'e' && argv[1][1] != 'd'))
{
cout << "Invalid command line arguments." << endl
<< "Please something like the following:" << endl
<< "\t To encrypt: \t image_encrypt -e <input> <output>\n"
<< "\t To decrypt: \t image_encrypt -d <input> <output>\n";
return 0;
}
// run encryption
try
{
// variables
encryptJpeg enc;
string key;
// set files
enc.setInFile(argv[2]);
enc.setOutFile(argv[3]);
// set key
cout << "Please enter a key: ";
cin >> key;
enc.setPlainKey(key);
// do the actual encryption
enc.process(argv[1][1]);
}
catch(encryptJpeg::invalidInFile)
{
cout << "That input file is not valid" << endl;
}
catch(encryptJpeg::invalidOutFile)
{
cout << "Could not open output file for writing" << endl;
}
catch(encryptJpeg::invalidAction)
{
cout << "The program encountered an internal error..." << endl;
}
return 0;
}