-
Notifications
You must be signed in to change notification settings - Fork 0
/
enc_doc.cpp
45 lines (39 loc) · 923 Bytes
/
enc_doc.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
#include"enc_doc.h"
string& Encrypt(string &passw){
char *password = nullptr;
password=new char[passw.length()];
strcpy(password,passw.c_str());
for(unsigned int i=0;i<strlen(password);i=i+3)
{
password[i]+=i;
}
for(unsigned int i=1;i<strlen(password);i=i+3)
{
password[i]-=i;
}
for(unsigned int i=2;i<strlen(password);i=i+3)
{
password[i]=password[i]*2;
}
passw=password;
return passw;
}
string& Decode(string &passw){
char *password = nullptr;
password=new char[passw.length()];
strcpy(password,passw.c_str());
for(unsigned int i=2;i<strlen(password);i=i+3)
{
password[i]=password[i]/2;
}
for(unsigned int i=1;i<strlen(password);i=i+3)
{
password[i]+=i;
}
for(unsigned int i=0;i<strlen(password);i=i+3)
{
password[i]-=i;
}
passw=password;
return passw;
}