资源简介
MD5的c++算法,在vc6.0 和vs2010 上测试都正常,绝对可以用

代码片段和文件信息
#include “md5.h“
#include “stdio.h“
#include “memory.h“
#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 (UINT32 a[4] unsigned char b[64]);
static void Encode (unsigned char * UINT32 * unsigned int);
static void Decode (UINT32 * unsigned char * 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
};
#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)))
#define ROTATE_LEFT(x n) (((x) << (n)) | ((x) >> (32-(n))))
#define FF(a b c d x s ac) { \
(a) += F ((b) (c) (d)) + (x) + (UINT32)(ac); \
(a) = ROTATE_LEFT ((a) (s)); \
(a) += (b); \
}
#define GG(a b c d x s ac) { \
(a) += G ((b) (c) (d)) + (x) + (UINT32)(ac); \
(a) = ROTATE_LEFT ((a) (s)); \
(a) += (b); \
}
#define HH(a b c d x s ac) { \
(a) += H ((b) (c) (d)) + (x) + (UINT32)(ac); \
(a) = ROTATE_LEFT ((a) (s)); \
(a) += (b); \
}
#define II(a b c d x s ac) { \
(a) += I ((b) (c) (d)) + (x) + (UINT32)(ac); \
(a) = ROTATE_LEFT ((a) (s)); \
(a) += (b); \
}
void MD5Init (MD5_CTX *context)
{
context->count[0] = context->count[1] = 0;
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
}
void MD5Update (MD5_CTX *context unsigned char *input unsigned int inputLen)
{
unsigned int i index partLen;
index = (unsigned int)((context->count[0] >> 3) & 0x3F);
if ((context->count[0] += ((UINT32)inputLen << 3))
< ((UINT32)inputLen << 3))
context->count[1]++;
context->count[1] += ((UINT32)inputLen >> 29);
partLen = 64 - index;
if (inputLen >= partLen) {
memcpy((unsigned char *)&context->buffer[index] (unsigned char *)input partLen);
MD5Transform (context->state context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
MD5Transform (context->state &input[i]);
index = 0;
}
else
i = 0;
memcpy((unsigned char *)&context->buffer[index] (unsigned char *)&input[i]
inputLen-i);
}
void MD5Final (unsigned char digest[16] MD5_CTX * context)
{
unsigned char bits[8];
unsigned int index padLen;
Encode (bits context->count 8);
index = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
MD5Update (context PADDING padLen);
MD5Update (context bits 8);
Encode (digest context->state 16);
memset ((unsigned char *)context 0 si
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7944 2012-03-16 21:02 md5.cpp
文件 494 2012-03-16 20:59 md5.h
----------- --------- ---------- ----- ----
8438 2
- 上一篇:C语言实现控制台扫雷小游戏
- 下一篇:各种排序算法的实现和性能比较C程序源代码
相关资源
- 移木块游戏,可以自编自玩,vc6.0编写
- 3des加密算法C语言实现
- C++纯文字DOS超小RPG游戏
- 安科瑞智能电能表MODBUS通讯程序 VC6
- DES加密算法C语言实现
- C语言实现的DES对称加密算法
- 九齐单片机源码
- Qt画图工具源码(qgraphics draw)
- qt 串口助手源码
- modbus 主机源码
- 《LINUX C编程从初学到精通》光盘源码
- OLED驱动源码
- tm1650+stm32f103源码(board_tm1650.c)
- cheat engine 7.2源码
- CrySearch内存搜索器源码
- FTP客户端源码(c++)
- MFC视频播放器源码(支持avi/wma/mp3等格
- CreatBitmap图片合成源码
- vs2008 can总线通讯源码
- 宠物管理系统课程设计(源码+数据库
- Windows扩展命令程序(源码)
- c语言实现火车订票系统(控制台)源
- 鼠标连点器(附源码)
- c++ 简易贪吃蛇源码
- 国密SM4加密_2020
- 杀毒软件源码
- 经典外汇智能交易程序Amazing3.1源码(
- 微型文件系统源码(FatFs)
- 海康私有流分析接口源码(附使用说
- VC6 USB开发源码
评论
共有 条评论