-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword.h
More file actions
49 lines (45 loc) · 798 Bytes
/
password.h
File metadata and controls
49 lines (45 loc) · 798 Bytes
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
// password.h : Defines the password class.
//
class password
{
static void encrypt(char* input)
{
for (int i=0;input[i]!=0;i++) input[i]+=1;
}
static void decrypt(char* input)
{
for (int i=0;input[i]!=0;i++) input[i]-=1;
}
public:
bool static check(char* input)
{
char pwd[max];
char* decipher;
ifstream in("pwd.rob");
if (!in)
{
char default[]="robin";
encrypt(default);
ofstream out("pwd.rob");
if (!out) return false;
out<<default;
out.close();
in.open("pwd.rob");
}
in>>pwd;
in.close();
decrypt(pwd);
if (strcmp(pwd,input)==0) return true;
else return false;
}
bool static change(char* input)
{
char* cipher;
encrypt(input);
ofstream out("pwd.rob");
if (!out) return false;
out<<input;
out.close();
return true;
}
};