//md5.h头文件的内容开始
#pragma once
#define uchar unsigned char
typedef unsigned char *pointer;
typedef unsigned short int uint2;
typedef unsigned long int uint4;
#define proto_list(list) list
//md5 context.
typedef struct md5_ctx {
uint4 state[4]; // state (abcd)
uint4 count[2]; // number of bits, modulo 2^64 (lsb first)
unsigned char buffer[64]; // input buffer
} md5_ctx;
void md5init proto_list ((md5_ctx *));
void md5update proto_list
((md5_ctx *, unsigned char *, unsigned int));
void md5final proto_list ((unsigned char [16], md5_ctx *));
/* constants for md5transform routine.
*/
#define s11 7
#define s12 12
#define s13 17
#define s14 22
#define s21 5
#define s22 9
#define s23 14
#define s24 20
#define s31 4
#define s32 11
#define s33 16
#define s34 23
#define s41 6
#define s42 10
#define s43 15
#define s44 21
static void md5transform proto_list ((uint4 [4], unsigned char [64]));
static void encode proto_list
((unsigned char *, uint4 *, unsigned int));
static void decode proto_list
((uint4 *, unsigned char *, unsigned int));
static void md5_memcpy proto_list ((pointer, pointer, unsigned int));
static void md5_memset proto_list ((pointer, int, unsigned int));
static unsigned char padding[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* f, g, h and i are basic md5 functions.
*/
#define f(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define g(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define h(x, y, z) ((x) ^ (y) ^ (z))
#define i(x, y, z) ((y) ^ ((x) | (~z)))
/* rotate_left rotates x left n bits.
*/
#define rotate_left(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* ff, gg, hh, and ii transformations for rounds 1, 2, 3, and 4.
rotation is separate from addition to prevent recomputation.
*/
#define ff(a, b, c, d, x, s, ac) { \
(a) += f ((b), (c), (d)) + (x) + (uint4)(ac); \
(a) = rotate_left ((a), (s)); \
(a) += (b); \
}
#define gg(a, b, c, d, x, s, ac) { \
(a) += g ((b), (c), (d)) + (x) + (uint4)(ac); \
(a) = rotate_left ((a), (s)); \
(a) += (b); \
}
#define hh(a, b, c, d, x, s, ac) { \
(a) += h ((b), (c), (d)) + (x) + (uint4)(ac); \
(a) = rotate_left ((a), (s)); \
(a) += (b); \
}
#define ii(a, b, c, d, x, s, ac) { \
(a) += i ((b), (c), (d)) + (x) + (uint4)(ac); \
(a) = rotate_left ((a), (s)); \
(a) += (b); \
}
class cmd5
{
private:
void md5update (md5_ctx *context, unsigned char *input, unsigned int inputlen);
void md5final (unsigned char digest[16], md5_ctx *context);
static void md5transform (uint4 state[4], unsigned char block[64]);
void tohex(byte * out,byte * lpbuffer,dword dwsize);
public:
cmd5(void);
~cmd5(void);
void mdstring (uchar *string,uchar *out,int len);
};
//运行所需参数
#define test_block_len 1000
#define test_block_count 1000
static void mdstring proto_list ((char *));
static void mdtimetrial proto_list ((void));
static void mdtestsuite proto_list ((void));
static void mdfile proto_list ((char *));
static void mdfilter proto_list ((void));
static void mdprint proto_list ((unsigned char [16]));
#define md5_ctx md5_ctx
#define mdinit md5init
#define mdupdate md5update
#define mdfinal md5final
/* digests a string and prints the result.
*/
//md5.h文件结束
//md5.cap文件内容开始
#include "stdafx.h"
#include ".\md5.h"
cmd5::cmd5(void)
{
}
cmd5::~cmd5(void)
{
}
/* md5 initialization. begins an md5 operation, writing a new context.
*/
void md5init (md5_ctx *context)
{
context->count[0] = context->count[1] = 0;
/* load magic initialization constants.
*/
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
}