-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecrypt.h
86 lines (79 loc) · 1.57 KB
/
decrypt.h
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
#ifndef DECRYPT_H
#define DECRYPT_H
#include <iostream>
#include <random>
#include <vector>
#include <fstream>
#include <string>
using namespace std;
string decrypt(string key){
fstream pswrdFile;
int rand_num = 0;
vector <int> dec;
pswrdFile.open("passwords.txt", ios::in);
if(pswrdFile.is_open()){
string lines;
string line;
while(getline(pswrdFile, lines)){
line = lines;
int i = 0;
string s = "";
char hit = line[i];
while(hit != ':'){
s+=line[i];
i++;
hit = line[i];
}
i+=2;
char e = line[i];
if(key == s){
int tmp = 0;
while(1){
if(e == '&'){
i++;
e = line[i];
while(e != '\0'){
rand_num = rand_num*10 + (e - 48);
i++;
e = line[i];
}
dec.push_back(rand_num);
break;
}
else if(e != '@' && e != '#' && e != '$'){
tmp = tmp*10 + (e - 48);
i++;
e = line[i];
continue;
}
else if(e == '@' || e == '#' || e == '$'){
dec.push_back(tmp);
tmp = 0;
i++;
e = line[i];
}
else{
i++;
e = line[i];
continue;
}
}
}
else{
continue;
}
}
}
string decrypted = "";
if(dec.size() != 0){
for(int val : dec){
char x = val - rand_num;
decrypted+=x;
}
return decrypted;
}
else{
return "Err";
}
}
#endif