-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
133 lines (92 loc) · 1.93 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
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
#include <iostream>
#include <conio.h>
#include <fstream>
#include <string.h>
#include <stdlib.h>
using namespace std;
char pass[50];
void encrypt()
{
char ch;
int z[50], i;
ifstream ifile;
ofstream ofile;
ifile.open("input.txt");
ofile.open("output.txt");
cout << "\n\n\tPASSWORD CAN ONLY BE a-z WITHOUT SPACES" ;
cout << "\n\n\tENTER PASSWORD : " ;
cin>>pass;
for(int i=0; i<strlen(pass);i++)
{
z[i]=pass[i]-96;
}
system("cls");
cout<<"\n\n\n\n\n\t\t\t\t\t PLEASE WAIT.";
i=0;
while(ifile.get(ch))
{
if(i==strlen(pass))
i=0;
ofile.put(ch+z[i]);
i++;
}
system("cls");
cout<<"\n\n\n\n\n\t\t\t\t\tENCRYPT DONE, PRESS ANY KEY.";
getch();
ifile.close();
ofile.close();
}
void decrypt()
{
char ch;
int z[50], i;
ifstream ifile;
ofstream ofile;
ifile.open("input.txt");
ofile.open("output.txt");
cout << "\n\n\tPASSWORD CAN ONLY BE a-z WITHOUT SPACES" ;
cout << "\n\n\tENTER PASSWORD : " ;
cin>>pass;
for(int i=0; i<strlen(pass);i++)
{
z[i]=pass[i]-96;
}
system("cls");
cout<<"\n\n\n\n\n\t\t\t\t\t PLEASE WAIT.";
i=0;
while(ifile.get(ch))
{
if(i==strlen(pass))
i=0;
ofile.put(ch-z[i]);
i++;
}
system("cls");
cout<<"\n\n\n\n\n\t\t\t\t\tDECRYPT DONE, PRESS ANY KEY.";
getch();
ifile.close();
ofile.close();
}
int main()
{
int choice;
while(1)
{
system("cls");
cout << "\n\n\n\t\t0. To Exit" ;
cout << "\n\t\t1. To Encrypt" ;
cout << "\n\t\t2. TO Decrypt" ;
cout << "\n\n\t\t Your choice : " ;
cin>>choice;
system("cls");
switch(choice)
{
case 0 : exit(0); break;
case 1 : encrypt(); break ;
case 2 : decrypt(); break;
default : system("cls");
cout<<"\n\n\n\t\t\tWRONG CHOICE";
}
}
return 0;
}