File: MD5.h

package info (click to toggle)
znc 0.045-3%2Betch3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 1,120 kB
  • ctags: 2,324
  • sloc: cpp: 17,406; sh: 2,380; perl: 448; makefile: 134
file content (56 lines) | stat: -rw-r--r-- 952 bytes parent folder | download | duplicates (3)
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
/* C implementation by Christophe Devine, C++ "class-ified" by [T3] */

#ifndef _MD5_H
#define _MD5_H

#include <string>
using std::string;

#ifndef uint8
#define uint8  unsigned char
#endif

#ifndef uint32
#define uint32 unsigned long int
#endif

typedef struct
{
    uint32 total[2];
    uint32 state[4];
    uint8 buffer[64];
}
md5_context;

class CMD5 {
protected:
	char m_szMD5[33];

public:
	CMD5();
	CMD5(const string& sText);
	CMD5(const char* szText, uint32 nTextLen);
	virtual ~CMD5();

	operator string() const
	{
		return (string) m_szMD5;
	}

	operator char*() const
	{
		return (char*)m_szMD5;
	}

	char* MakeHash(const char* szText, uint32 nTextLen);

protected:
	void md5_starts( md5_context *ctx ) const;
	void md5_update( md5_context *ctx, uint8 *input, uint32 length ) const;
	void md5_finish( md5_context *ctx, uint8 digest[16] ) const;

private:
	void md5_process( md5_context *ctx, uint8 data[64] ) const;
};

#endif /* _MD5_H */