admin管理员组

文章数量:1531425

2024年3月21日发(作者:)

/*

从网上找的内嵌汇编的MD5代码,,bcb6下面调试通过。

优点是速度很快,缺点是只能在Windows下使用。

最后面有现成的 for bcb 的两个函数。

*/

#include

#include

////////////////////////////////////////////////////////////////////////////////

typedef struct {

DWORD state[4]; //encypted message

DWORD count[2]; //bits of plaintext

unsigned char buffer[64];

}MD5_CTX;

////////////////////////////////////////////////////////////////////////////////

#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

#define a esi

#define b edi

#define c edx

#define d ebx

#define tmp1 eax

#define tmp2 ecx

#define x(i) [x+4*i]

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 FF(a, b, c, d, x, s, ac)

__asm mov tmp1,b;

__asm and tmp1,c;

__asm mov tmp2,b;

__asm not tmp2;

__asm and tmp2,d;

__asm or tmp2,tmp1;

__asm lea a,[tmp2+a+ac];

__asm add a,x;

__asm rol a,s;

__asm add a,b;

#define GG(a, b, c, d, x, s, ac)

__asm mov tmp1,b;

__asm and tmp1,d;

__asm mov tmp2,d;

__asm not tmp2;

__asm and tmp2,c;

__asm or tmp2,tmp1;

__asm lea a,[tmp2+a+ac];

__asm add a,x;

__asm rol a,s;

__asm add a,b;

#define HH(a,b,c, d, x, s, ac)

__asm mov tmp2,b;

__asm xor tmp2,c;

__asm xor tmp2,d;

__asm lea a,[tmp2+a+ac];

__asm add a,x;

__asm rol a,s;

__asm add a,b;

#define II(a, b, c, d, x, s, ac)

本文标签: 速度只能缺点汇编内嵌