blob: 726520a806909b10869bbbf7975443a02316022f [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001#ifndef MD5_H
2#define MD5_H
3
4typedef struct
5{
6 unsigned int count[2];
7 unsigned int state[4];
8 unsigned char buffer[64];
9}MD5_CTX;
10
11
12#define F(x,y,z) ((x & y) | (~x & z))
13#define G(x,y,z) ((x & z) | (y & ~z))
14#define H(x,y,z) (x^y^z)
15#define I(x,y,z) (y ^ (x | ~z))
16#define ROTATE_LEFT(x,n) ((x << n) | (x >> (32-n)))
17#define FF(a,b,c,d,x,s,ac) \
18{ \
19 a += F(b,c,d) + x + ac; \
20 a = ROTATE_LEFT(a,s); \
21 a += b; \
22}
23#define GG(a,b,c,d,x,s,ac) \
24{ \
25 a += G(b,c,d) + x + ac; \
26 a = ROTATE_LEFT(a,s); \
27 a += b; \
28}
29#define HH(a,b,c,d,x,s,ac) \
30{ \
31 a += H(b,c,d) + x + ac; \
32 a = ROTATE_LEFT(a,s); \
33 a += b; \
34}
35#define II(a,b,c,d,x,s,ac) \
36{ \
37 a += I(b,c,d) + x + ac; \
38 a = ROTATE_LEFT(a,s); \
39 a += b; \
40}
41
42//int get_md5_32(unsigned char *data, int len, unsigned char *digest);
43
44void MD5Init(MD5_CTX *context);
45void MD5Update(MD5_CTX *context,unsigned char *input,unsigned int inputlen);
46void MD5Final(MD5_CTX *context,unsigned char digest[16]);
47void MD5Transform(unsigned int state[4],unsigned char block[64]);
48void MD5Encode(unsigned char *output,unsigned int *input,unsigned int len);
49void MD5Decode(unsigned int *output,unsigned char *input,unsigned int len);
50
51
52#endif