]> git.sesse.net Git - freerainbowtables/blob - Common/rt api/tmp/HashRoutine.cpp
b61ae63c9737c64054659292d1d57672fcfd970e
[freerainbowtables] / Common / rt api / tmp / HashRoutine.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)
9 #endif
10
11 #include "HashRoutine.h"
12 #include "HashAlgorithm.h"
13
14 //////////////////////////////////////////////////////////////////////
15
16 CHashRoutine::CHashRoutine()
17 {
18         // Notice: MIN_HASH_LEN <= nHashLen <= MAX_HASH_LEN
19
20         AddHashRoutine("lm",   HashLM,   8);
21         AddHashRoutine("md5",  HashMD5,  16);
22         AddHashRoutine("sha1", HashSHA1, 20);
23         AddHashRoutine("ntlm", HashNTLM, 16);
24 }       
25
26 CHashRoutine::~CHashRoutine()
27 {
28 }
29
30 void CHashRoutine::AddHashRoutine(string sHashRoutineName, HASHROUTINE pHashRoutine, int nHashLen)
31 {
32         vHashRoutineName.push_back(sHashRoutineName);
33         vHashRoutine.push_back(pHashRoutine);
34         vHashLen.push_back(nHashLen);
35 }
36
37 string CHashRoutine::GetAllHashRoutineName()
38 {
39         string sRet;
40         int i;
41         for (i = 0; i < vHashRoutineName.size(); i++)
42                 sRet += vHashRoutineName[i] + " ";
43
44         return sRet;
45 }
46
47 void CHashRoutine::GetHashRoutine(string sHashRoutineName, HASHROUTINE& pHashRoutine, int& nHashLen)
48 {
49         int i;
50         for (i = 0; i < vHashRoutineName.size(); i++)
51         {
52                 if (sHashRoutineName == vHashRoutineName[i])
53                 {
54                         pHashRoutine = vHashRoutine[i];
55                         nHashLen = vHashLen[i];
56                         return;
57                 }
58         }
59
60         pHashRoutine = NULL;
61         nHashLen = 0;
62 }