-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathHashSet.cpp
136 lines (114 loc) · 2.01 KB
/
HashSet.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
134
135
136
/*
RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
Copyright (C) Zhu Shuanglei <[email protected]>
*/
#ifdef _WIN32
#pragma warning(disable : 4786)
#endif
#include "HashSet.h"
CHashSet::CHashSet()
{
}
CHashSet::~CHashSet()
{
}
void CHashSet::AddHash(string sHash)
{
if (sHash == "aad3b435b51404ee")
return;
int i;
for (i = 0; i < m_vHash.size(); i++)
{
if (m_vHash[i] == sHash)
return;
}
//printf("debug: adding hash %s\n", sHash.c_str());
m_vHash.push_back(sHash);
m_vFound.push_back(false);
m_vPlain.push_back("");
m_vBinary.push_back("");
}
bool CHashSet::AnyhashLeft()
{
int i;
for (i = 0; i < m_vHash.size(); i++)
{
if (!m_vFound[i])
return true;
}
return false;
}
bool CHashSet::AnyHashLeftWithLen(int nLen)
{
int i;
for (i = 0; i < m_vHash.size(); i++)
{
if (!m_vFound[i])
if (m_vHash[i].size() == nLen * 2)
return true;
}
return false;
}
void CHashSet::GetLeftHashWithLen(vector<string>& vHash, int nLen)
{
vHash.clear();
int i;
for (i = 0; i < m_vHash.size(); i++)
{
if (!m_vFound[i])
if (m_vHash[i].size() == nLen * 2)
vHash.push_back(m_vHash[i]);
}
}
void CHashSet::SetPlain(string sHash, string sPlain, string sBinary)
{
int i;
for (i = 0; i < m_vHash.size(); i++)
{
if (m_vHash[i] == sHash)
{
m_vFound[i] = true;
m_vPlain[i] = sPlain;
m_vBinary[i] = sBinary;
return;
}
}
}
bool CHashSet::GetPlain(string sHash, string& sPlain, string& sBinary)
{
if (sHash == "aad3b435b51404ee")
{
sPlain = "";
sBinary = "";
return true;
}
int i;
for (i = 0; i < m_vHash.size(); i++)
{
if (m_vHash[i] == sHash)
{
if (m_vFound[i])
{
sPlain = m_vPlain[i];
sBinary = m_vBinary[i];
return true;
}
}
}
return false;
}
int CHashSet::GetStatHashFound()
{
int nHashFound = 0;
int i;
for (i = 0; i < m_vHash.size(); i++)
{
if (m_vFound[i])
nHashFound++;
}
return nHashFound;
}
int CHashSet::GetStatHashTotal()
{
return m_vHash.size();
}