-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
146 lines (122 loc) · 5.22 KB
/
main.cpp
File metadata and controls
146 lines (122 loc) · 5.22 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include "mainheader.h"
void getInputOutput(string&, string&, string&);
void printTitle();
int main(){
char charHexaFile[] = "hex\\1.hex";
string hexaFile = charHexaFile;
string input = " ", output = " ", key = " ";
char choice;
do
{
system("cls");
system("Color 03");
printTitle();
cin>>choice;
cin.ignore();
if(choice=='1')
{
system("Color 06");
system("cls");
cout<<endl;
cout<<"\t\t\t------------*********//////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\*********------------\n";
cout<<"\t\t\t-----------******************\"Encryption\"******************-----------\n";
cout<<"\t\t\t------------*********\\\\\\\\\\\\\\\\\\\\\\\\\\\\//////////////*********------------\n";
cout<<"\n\t**Input file path should be ended with it's appropriate extension. e.g(text.txt)**"<<endl;
cout<<"\n\t**Output file path may or may not have an extension.**\n"<<endl;
getInputOutput(input, output, key);
Hexadecimal *inputFile = new FileToHexa(input, hexaFile);
bool okay = inputFile->convertfile();
if(okay)
{
cout<<"\n==================================PLEASE WAIT YOUR WORK IS IN PROGRESS...======================================\n";
XORCipher *encryption = new Encryption(key, hexaFile, output);
bool check = encryption->performXOR();
inputFile->deleteHexaFile(charHexaFile);
if(check)
{
system("cls");
system("Color 02");
cout<<"\n\t\tFile is successfully encrypted."<<endl;
cout<<"\n\t\tPath : \""<<output<<"\""<<endl<<endl;
system("pause");
}
}
}else if(choice=='2')
{
system("Color 06");
system("cls");
cout<<endl;
cout<<"\t\t\t------------*********//////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\*********------------\n";
cout<<"\t\t\t-----------******************\"Decryption\"******************-----------\n";
cout<<"\t\t\t------------*********\\\\\\\\\\\\\\\\\\\\\\\\\\\\//////////////*********------------\n";
cout<<"\n\t**Input file path may or may not have an extension.**"<<endl;
cout<<"\n\t**Output file path should be ended with it's appropriate extension. e.g(text.txt)**\n"<<endl;
getInputOutput(input, output, key);
XORCipher *decryption = new Decryption(key, hexaFile, input);
cout<<"\n==================================PLEASE WAIT YOUR WORK IS IN PROGRESS...======================================\n";
bool okay = decryption->performXOR();
if(okay)
{
Hexadecimal *outputFile = new HexaToFile(hexaFile, output);
bool check = outputFile->convertfile();
outputFile->deleteHexaFile(charHexaFile);
if(check)
{
system("cls");
system("Color 02");
cout<<"\n\t\tFile is successfully decrypted."<<endl;
cout<<"\n\t\tPath : \""<<output<<"\""<<endl<<endl;
system("pause");
}
}
}else if(choice=='3')
{
//Output Developer Info
system("cls");
system("Color 0a");
cout<<endl;
cout<<"\t\t\t------------*********//////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\*********------------\n";
cout<<"\t\t\t-----------******************\"Developed By:\"******************-----------\n";
cout<<"\t\t\t------------*********\\\\\\\\\\\\\\\\\\\\\\\\\\\\//////////////*********------------\n";
cout<<"\n\n\t\t\t\t\t\t\"Abdullah\""<<endl<<endl;
cout<<"\t\t\t\t\t\t\"Anees Ahmed\""<<endl<<endl;
cout<<"\t\t\t\t\t\t\"Zaighum Ali\""<<endl<<endl;
cout<<"\t\t\t\t\t\t\"Usman Abbasi\""<<endl<<endl;
system("pause");
}else if(choice=='4')
{
choice = 'q';
}else
{
cout<<"Invalid choice.\n";
}
}while(choice!='q');
return 0;
}
void getInputOutput(string &in, string &out, string &k)
{
cout<<"\n\t\t\tEnter the path of input file : ";
getline(cin, in);
cout<<endl;
cout<<"\n\t\t\tEnter the path of output file : ";
getline(cin, out);
cout<<endl;
cout<<"\n\t\t\tEnter key : ";
getline(cin, k);
}
void printTitle()
{
cout<<endl;
cout<<"\t\t\t--------------*********////////////\\\\\\\\\\\\\\\\\\\\\\\\*********--------------\n";
cout<<"\t\t\t-------------*********/////////////\\\\\\\\\\\\\\\\\\\\\\\\\\*********-------------\n";
cout<<"\t\t\t------------*********//////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\*********------------\n";
cout<<"\t\t\t-----------*********\"Encryption & Decryption Tool\"*********-----------\n";
cout<<"\t\t\t------------*********\\\\\\\\\\\\\\\\\\\\\\\\\\\\//////////////*********------------\n";
cout<<"\t\t\t-------------*********\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////*********-------------\n";
cout<<"\t\t\t--------------*********\\\\\\\\\\\\\\\\\\\\\\\\////////////*********-------------\n\n\n";
cout<<"\t\t\t\t\t\t1. \"Encryption\""<<endl<<endl;
cout<<"\t\t\t\t\t\t2. \"Decryption\""<<endl<<endl;
cout<<"\t\t\t\t\t\t3. \"Developer Info\""<<endl<<endl;
cout<<"\t\t\t\t\t\t4. \"Exit\""<<endl<<endl;
cout<<"\t\t\t\t\t\t\t";
}