ZNC  trunk
MD5.h
Go to the documentation of this file.
1 /* C implementation by Christophe Devine, C++ "class-ified" by [T3] */
2 
3 #ifndef ZNC_MD5_H
4 #define ZNC_MD5_H
5 
6 #include <znc/zncconfig.h>
7 #include <string>
8 using std::string;
9 
10 #ifndef uint8
11 #define uint8 unsigned char
12 #endif
13 
14 #ifndef uint32
15 #define uint32 unsigned long int
16 #endif
17 
18 typedef struct {
19  uint32 total[2];
20  uint32 state[4];
21  uint8 buffer[64];
22 } md5_context;
23 
24 class CMD5 {
25  protected:
26  char m_szMD5[33];
27 
28  public:
29  CMD5();
30  CMD5(const string& sText);
31  CMD5(const char* szText, uint32 nTextLen);
32  ~CMD5();
33 
34  operator string() const { return (string)m_szMD5; }
35 
36  operator char*() const { return (char*)m_szMD5; }
37 
38  char* MakeHash(const char* szText, uint32 nTextLen);
39 
40  protected:
41  void md5_starts(md5_context* ctx) const;
42  void md5_update(md5_context* ctx, const uint8* input, uint32 length) const;
43  void md5_finish(md5_context* ctx, uint8 digest[16]) const;
44 
45  private:
46  void md5_process(md5_context* ctx, const uint8 data[64]) const;
47 };
48 
49 #endif /* ZNC_MD5_H */
#define uint8
Definition: MD5.h:11
#define uint32
Definition: MD5.h:15
Definition: MD5.h:24
char * MakeHash(const char *szText, uint32 nTextLen)
void md5_starts(md5_context *ctx) const
char m_szMD5[33]
Definition: MD5.h:26
void md5_finish(md5_context *ctx, uint8 digest[16]) const
CMD5(const string &sText)
void md5_update(md5_context *ctx, const uint8 *input, uint32 length) const
CMD5(const char *szText, uint32 nTextLen)
Definition: MD5.h:18