-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
59 lines (55 loc) · 1.17 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
#include <iostream>
#include <cstring>
#include "utility.h"
#include "tripledes.h"
using namespace std;
int main(int argc, char *argv[])
{
char *info;
int infoSize = 0;
if (argc == 1)
{
message();
}
else if (!strcmp(argv[1], "-e"))
{
if (argc == 6)
{
info = readFile(argv[2], infoSize, true);
if (info == NULL)
{
return 0;
}
char **keys = keysFormat(argv[3], argv[4], argv[5]);
tripleDESencode(info, infoSize, keys);
writeFile(argv[2], info, infoSize, false);
}
else
{
message();
}
}
else if (!strcmp(argv[1], "-d"))
{
if (argc == 6)
{
info = readFile(argv[2], infoSize, false);
if (info == NULL)
{
return 0;
}
char **keys = keysFormat(argv[3], argv[4], argv[5]);
tripleDESdecode(info, infoSize, keys);
writeFile(argv[2], info, infoSize, true);
}
else
{
message();
}
}
else
{
message();
}
return 0;
}