-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDXOR.txt
More file actions
45 lines (38 loc) · 932 Bytes
/
Copy pathDXOR.txt
File metadata and controls
45 lines (38 loc) · 932 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
int word = 0;
int digit = 0;
int hashValue = 0;
int mod = 0;
string value;
vector <string> Values;
vector <int> numbers;
word = key.length() / 7;
mod = key.length() % 7;
if (key.length() > 7){
for (int i = 0; i < word; i++){
value = key.substr((i * 7), 7);
Values.push_back(value);
}
for (int i = 0; i < int(Values.size()); i++){
stringstream s(Values[i]);
s >> hex >> digit;
numbers.push_back(digit);
s.clear();
}
if (mod != 0){
key = key.substr(word * 7, 7);
stringstream ss(key);
ss >> hex >> digit;
numbers.push_back(digit);
ss.clear();
}
for (int i = 0; i < int(numbers.size()); i++){
hashValue = hashValue^numbers[i];
}
return hashValue;
}
else {
stringstream sin(key);
sin >> hex >> digit;
sin.clear();
return digit;
}