]> git.sesse.net Git - freerainbowtables/blob - Client Applications/rcracki_mt/HashSet.cpp
rcracki_mt updated to rti2
[freerainbowtables] / Client Applications / rcracki_mt / HashSet.cpp
1 /*
2    RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
3
4    Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
5 */
6
7 #ifdef _WIN32
8         #pragma warning(disable : 4786 4267 4018)
9 #endif
10
11 #include "HashSet.h"
12
13 CHashSet::CHashSet()
14 {
15 }
16
17 CHashSet::~CHashSet()
18 {
19 }
20
21 void CHashSet::AddHash(string sHash)
22 {
23         if (sHash == "aad3b435b51404ee")
24                 return;
25
26         int i;
27         for (i = 0; i < m_vHash.size(); i++)
28         {
29                 if (m_vHash[i] == sHash)
30                         return;
31         }
32
33         //printf("debug: adding hash %s\n", sHash.c_str());
34
35         m_vHash.push_back(sHash);
36         m_vFound.push_back(false);
37         m_vPlain.push_back("");
38         m_vBinary.push_back("");
39 }
40
41 string CHashSet::GetHashInfo(int i)
42 {
43         string found;
44         if (m_vFound[i])
45                 found = "1";
46         else
47                 found = "0";
48
49         string buffer = m_vHash[i] + ":" + found + ":" + m_vPlain[i] + ":" + m_vBinary[i];
50
51         return buffer;
52 }
53
54 bool CHashSet::AnyhashLeft()
55 {
56         int i;
57         for (i = 0; i < m_vHash.size(); i++)
58         {
59                 if (!m_vFound[i])
60                         return true;
61         }
62
63         return false;
64 }
65
66 bool CHashSet::AnyHashLeftWithLen(int nLen)
67 {
68         int i;
69         for (i = 0; i < m_vHash.size(); i++)
70         {
71                 if (!m_vFound[i])
72                         if (m_vHash[i].size() == nLen * 2)
73                                 return true;
74         }
75
76         return false;
77 }
78
79 void CHashSet::GetLeftHashWithLen(vector<string>& vHash, int nLen)
80 {
81         vHash.clear();
82
83         int i;
84         for (i = 0; i < m_vHash.size(); i++)
85         {
86                 if (!m_vFound[i])
87                         if (m_vHash[i].size() == nLen * 2)
88                                 vHash.push_back(m_vHash[i]);
89         }
90 }
91
92 void CHashSet::AddHashInfo(string sHash, bool found, string sPlain, string sBinary)
93 {
94         int i;
95         for (i = 0; i < m_vHash.size(); i++)
96         {
97                 if (m_vHash[i] == sHash)
98                         return;
99         }
100
101         m_vHash.push_back(sHash);
102         m_vFound.push_back(found);
103         m_vPlain.push_back(sPlain);
104         m_vBinary.push_back(sBinary);
105 }
106
107 void CHashSet::SetPlain(string sHash, string sPlain, string sBinary)
108 {
109         int i;
110         for (i = 0; i < m_vHash.size(); i++)
111         {
112                 if (m_vHash[i] == sHash)
113                 {
114                         m_vFound[i]    = true;
115                         m_vPlain[i]    = sPlain;
116                         m_vBinary[i]   = sBinary;
117                         return;
118                 }
119         }
120 }
121
122 bool CHashSet::GetPlain(string sHash, string& sPlain, string& sBinary)
123 {
124         if (sHash == "aad3b435b51404ee")
125         {
126                 sPlain  = "";
127                 sBinary = "";
128                 return true;
129         }
130
131         int i;
132         for (i = 0; i < m_vHash.size(); i++)
133         {
134                 if (m_vHash[i] == sHash)
135                 {
136                         if (m_vFound[i])
137                         {
138                                 sPlain  = m_vPlain[i];
139                                 sBinary = m_vBinary[i];
140                                 return true;
141                         }
142                 }
143         }
144
145         return false;
146 }
147
148 int CHashSet::GetStatHashFound()
149 {
150         int nHashFound = 0;
151         int i;
152         for (i = 0; i < m_vHash.size(); i++)
153         {
154                 if (m_vFound[i])
155                         nHashFound++;
156         }
157
158         return nHashFound;
159 }
160
161 int CHashSet::GetStatHashTotal()
162 {
163         return m_vHash.size();
164 }