]> git.sesse.net Git - freerainbowtables/blob - Common/rt api/Public.h
misc cleanup
[freerainbowtables] / Common / rt api / Public.h
1 /*
2  * freerainbowtables is a project for generating, distributing, and using
3  * perfect rainbow tables
4  *
5  * Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
6  * Copyright 2009, 2010 DaniĆ«l Niggebrugge <niggebrugge@fox-it.com>
7  * Copyright 2009, 2010 James Nobis <frt@quelrod.net>
8  *
9  * This file is part of freerainbowtables.
10  *
11  * freerainbowtables is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 2 of the License.
14  *
15  * freerainbowtables is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with freerainbowtables.  If not, see <http://www.gnu.org/licenses/>.
22  */
23
24 #ifndef _PUBLIC_H
25 #define _PUBLIC_H
26
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30
31 #include <string>
32 #include <vector>
33 #include <list>
34
35 #include "global.h"
36
37 using namespace std;
38
39 struct RainbowChain
40 {
41         uint64 nIndexS;
42         uint64 nIndexE;
43 };
44
45 struct RainbowChainCP
46 {
47         uint64 nIndexS;
48         uint64 nIndexE;
49         unsigned short nCheckPoint;
50 };
51 struct IndexChain
52 {
53         uint64 nPrefix;
54         uint32 nFirstChain;
55         uint32 nChainCount;
56 };
57 struct FoundRainbowChain
58 {
59         uint64 nIndexS;
60         int nIndexE;
61         int nCheckPoint;
62         int nGuessedPos;
63 };
64 struct ChainCheckChain
65 {
66         uint64 nIndexS;
67         int nGuessedPos;
68 };
69 struct IndexRow
70 {
71         uint64 prefix;
72         unsigned int prefixstart, numchains;
73 };
74
75 typedef struct
76 {
77         string sName;
78         int nPlainLenMin;
79         int nPlainLenMax;
80 } tCharset;
81
82 #define MAX_PLAIN_LEN 256
83 #define MIN_HASH_LEN  8
84 #define MAX_HASH_LEN  256
85 #define MAX_SALT_LEN  256
86
87 // XXX nmap is GPL2, will check newer releases regarding license
88 // Code comes from nmap, used for the linux implementation of kbhit()
89 #ifndef _WIN32
90 #include <unistd.h>
91 #include <termios.h>
92 #include <fcntl.h>
93
94 int tty_getchar();
95 void tty_done();
96 void tty_init();
97 void tty_flush(void);
98 // end nmap code
99
100 #endif
101
102 #if defined(_WIN32) && !defined(__GNUC__)
103         int gettimeofday( struct timeval *tv, struct timezone *tz );
104 #else
105         #include <sys/time.h>
106 #endif
107
108 timeval sub_timeofday( timeval tv2, timeval tv );
109
110 long GetFileLen(FILE* file);
111 string TrimString(string s);
112 bool boinc_ReadLinesFromFile(string sPathName, vector<string>& vLine);
113 bool ReadLinesFromFile(string sPathName, vector<string>& vLine);
114 bool SeperateString(string s, string sSeperator, vector<string>& vPart);
115 string uint64tostr(uint64 n);
116 string uint64tohexstr(uint64 n);
117 string HexToStr(const unsigned char* pData, int nLen);
118 unsigned long GetAvailPhysMemorySize();
119 string GetApplicationPath();
120 void ParseHash(string sHash, unsigned char* pHash, int& nHashLen);
121 bool GetHybridCharsets(string sCharset, vector<tCharset>& vCharset);
122 void Logo();
123 bool writeResultLineToFile(string sOutputFile, string sHash, string sPlain, string sBinary);
124
125 #endif