~ubuntu-branches/ubuntu/trusty/znc/trusty

« back to all changes in this revision

Viewing changes to MD5.h

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-05-06 09:18:27 UTC
  • mfrom: (21.1.5 experimental)
  • Revision ID: package-import@ubuntu.com-20130506091827-08sixjiyy3hjfx6b
Tags: 1.0-4
* Change section from znc-tcl to interpreters.
* Uploading to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* C implementation by Christophe Devine, C++ "class-ified" by [T3] */
2
 
 
3
 
#ifndef _MD5_H
4
 
#define _MD5_H
5
 
 
6
 
#include "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
 
{
20
 
    uint32 total[2];
21
 
    uint32 state[4];
22
 
    uint8 buffer[64];
23
 
}
24
 
md5_context;
25
 
 
26
 
class CMD5 {
27
 
protected:
28
 
        char m_szMD5[33];
29
 
 
30
 
public:
31
 
        CMD5();
32
 
        CMD5(const string& sText);
33
 
        CMD5(const char* szText, uint32 nTextLen);
34
 
        ~CMD5();
35
 
 
36
 
        operator string() const
37
 
        {
38
 
                return (string) m_szMD5;
39
 
        }
40
 
 
41
 
        operator char*() const
42
 
        {
43
 
                return (char*)m_szMD5;
44
 
        }
45
 
 
46
 
        char* MakeHash(const char* szText, uint32 nTextLen);
47
 
 
48
 
protected:
49
 
        void md5_starts( md5_context *ctx ) const;
50
 
        void md5_update( md5_context *ctx, const uint8 *input, uint32 length ) const;
51
 
        void md5_finish( md5_context *ctx, uint8 digest[16] ) const;
52
 
 
53
 
private:
54
 
        void md5_process( md5_context *ctx, const uint8 data[64] ) const;
55
 
};
56
 
 
57
 
#endif /* _MD5_H */