两段封包相关的C++函数求DELPHI写法 ( 积分: 50 )

  • 主题发起人 主题发起人 月之深蓝
  • 开始时间 开始时间

月之深蓝

Unregistered / Unconfirmed
GUEST, unregistred user!
以下函数如用DELPHI写该如何写
某程序封包加密和解密的算法
加密部分
void CCsuanfaDlg::jiami(DWORD qian8,DWORD hou8)
{
DWORD a,b,c;
esi=0;
for(int i=16;i!=0;i--)
{

a=qian8+esi; //EDX+ESI
b=a^0x5073425d;
a=qian8*16;
b+=a;
a=qian8/32;
a+=0x7c7f7e59;
c=a^b;
hou8+=c;
esi-=0x61c88647;
a=esi+hou8;
b=a^0x384b3a45;
a=hou8*16;
b+=a;
a=hou8/32;
a+=0x74477641;
c=b^a;
qian8+=c;

}
edx=qian8;
ecx=hou8;
}
解密部分
void CCsuanfaDlg::jiemi(DWORD qian8,DWORD hou8)
{
DWORD a,b,c;

for(int i=16;i!=0;i--)
{
a=esi+hou8;
b=a^0x384b3a45;
a=hou8*16;
b+=a;
a=hou8/32;
a+=0x74477641;
c=b^a;
qian8=qian8-c;

esi+=0x61c88647;

a=qian8+esi;
b=a^0x5073425d;
a=qian8*16;
b+=a;
a=qian8/32;
a+=0x7c7f7e59;
c=a^b;
hou8=hou8-c;
}
edx=qian8;
ecx=hou8;
}
 
以下函数如用DELPHI写该如何写
某程序封包加密和解密的算法
加密部分
void CCsuanfaDlg::jiami(DWORD qian8,DWORD hou8)
{
DWORD a,b,c;
esi=0;
for(int i=16;i!=0;i--)
{

a=qian8+esi; //EDX+ESI
b=a^0x5073425d;
a=qian8*16;
b+=a;
a=qian8/32;
a+=0x7c7f7e59;
c=a^b;
hou8+=c;
esi-=0x61c88647;
a=esi+hou8;
b=a^0x384b3a45;
a=hou8*16;
b+=a;
a=hou8/32;
a+=0x74477641;
c=b^a;
qian8+=c;

}
edx=qian8;
ecx=hou8;
}
解密部分
void CCsuanfaDlg::jiemi(DWORD qian8,DWORD hou8)
{
DWORD a,b,c;

for(int i=16;i!=0;i--)
{
a=esi+hou8;
b=a^0x384b3a45;
a=hou8*16;
b+=a;
a=hou8/32;
a+=0x74477641;
c=b^a;
qian8=qian8-c;

esi+=0x61c88647;

a=qian8+esi;
b=a^0x5073425d;
a=qian8*16;
b+=a;
a=qian8/32;
a+=0x7c7f7e59;
c=a^b;
hou8=hou8-c;
}
edx=qian8;
ecx=hou8;
}
 
好,帮顶



--------签名档---------------------------

比肩国内顶尖源码下载站点 -> 源码我爱你

http://www.source520.com
http://www.source520.net

80G源码电子书免费免注册下载,大量精辟技术文档库随时更新
******************************************************************
附:为了站点持续发展,现有本站近年来收藏的大量大型商业源码低价出售,
详情请进入以下链接查看:
http://www.source520.com/building_delphi.htm

浏览商业代码请从如下URL进入查看实物:
1.商业源码库1: ftp://source520see3:browse@61.152.199.245/
2.商业源码库2: ftp://source520see2:browse@61.152.199.245/
 
//Delphi7, WindowsXP 编译通过
//加密部分
procedure CCsuanfaDlg.jiami(qian8: DWORD ;hou8: DWORD);
var
a,b,c: DWORD;
i: integer;
begin
asm
mov esi, 0
end;

for i:=16 downto 0 do
begin
asm
mov eax, qian8
add eax, esi
mov a, eax
end;
//a:= qian8 + esi; //EDX+ESI (这是原文)

b:= a xor $5073425d;
a:= qian8 * 16;
b:= b + a;
a:= qian8 div 32;
a:= a + $7c7f7e59;
c:= a xor b;
hou8:= hou8 + c;
asm
mov eax, esi
sub eax, 61c88647H
mov esi, eax
end;
//esi-=0x61c88647; // (这是原文)

asm
mov eax, esi
add eax, hou8
mov a, eax
end;
//a=esi+hou8; // (这是原文)

b:= a xor $384b3a45;
a:= hou8 * 16;
b:= b + a;
a:= hou8 div 32;
a:= a + $74477641;
c:= b xor a;
qian8:= qian8 + c;
end;

asm
mov edx, qian8
mov ecx, hou8
end;
//edx=qian8; (这是原文)
//ecx=hou8;
end;

//解密部分
procedure CCsuanfaDlg.jiemi(qian8: DWORD; hou8: DWORD);
var
a,b,c: DWORD;
i: integer;
begin
for i:=16 downto 0 do
begin
asm
mov eax, esi
add eax, hou8
mov a, eax
end;
//a=esi+hou8; //(这是原文)
b:=a xor $384b3a45;
a:= hou8 * 16;
b:= b + a;
a:= hou8 div 32;
a:= a + $74477641;
c:= b xor a;
qian8:= qian8 - c;

asm
mov esi, $61c88647
end;
//esi+=$61c88647; //(这是原文)

asm
mov eax, qian8
add eax, esi
mov a, eax
end;
//a=qian8+esi; //(这是原文)

b:= a xor $5073425d;
a:= qian8 * 16;
b:= b + a;
a:= qian8 div 32;
a:= a + $7c7f7e59;
c:=a xor b;
hou8:= hou8 - c;
end;

asm
mov edx, qian8
mov ecx, hou8
end;
//edx=qian8; //(这是原文)
//ecx=hou8;
end;
 
好牛![:)]
 
edx,ecx,esi:dword;
procedure jiami(qian8,hou8:dword);
procedure jiemi(qian8,hou8:dword);
implementation

{$R *.dfm}
procedure jiami(qian8,hou8:dword);
var
a,b,c:dword;
i:Integer;
begin
esi := 0;
for i:=16 downto 1 do
begin
a := qian8+esi;
b := a xor $5073425d;
a := qian8*16;
b := b + a;
a := trunc(qian8/32);
a := a + $7c7f7e59;
c := a xor b;
hou8 := hou8+c;
esi := esi - $61c88647;
a := esi + hou8;
b := a xor $384b3a45;
a := hou8*16;
b := b +a;
a := trunc(hou8/32);
a := a + $74477641;
c := b xor a;
qian8 := qian8 +c;
end;
edx := qian8;
ecx := hou8;
end;

procedure jiemi(qian8,hou8:dword);
var
a,b,c:dword;
i:Integer;
begin
for i := 16 downto 1 do
begin
a := esi+hou8;
b := a xor $384b3a45;
a := hou8 * 16;
b := b +a;
a := trunc(hou8/32);
a := a + $74477641;
c := b xor a;
qian8 := qian8-c;
esi := esi + $61c88647;
a := qian8 + esi;
b := a xor $5073425d;
a := qian8*16;
b := b +a;
a := trunc(qian8/32);
a := a + $7c7f7e59;
c := a xor b;
hou8 := hou8 -c;
end;
edx := qian8;
ecx := hou8
end;
procedure TForm1.Button1Click(Sender: TObject);
begin//test
edx := 100;
ecx := 100;
jiami(edx,ecx);
memo1.Lines.Add(inttostr(edx)+','+inttostr(ecx));
jiemi(edx,ecx);
memo1.Lines.Add(inttostr(edx)+','+inttostr(ecx));
end;
 
赞一个,译的很到位.
 
接受答案了.
 
后退
顶部