鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 网站安全 > 加密解密 > >

千年加密解密代码(delphi)

来源:互联网 作者:佚名 时间:2015-10-09 06:19
代码 是从 www.GameRes.com 转载的,作者是bbs的 kissyll,感谢他。 //////////////原文内容 ////////////////// 千年 加密 解密 代码 (delphi) 千年 加密 解密 代码 ....虽然看起来挺复杂的.我是对应汇编的.编译后几乎和游戏客户端里的一样...保证了速度..
代码是从 www.GameRes.com 转载的,作者是bbs的 kissyll,感谢他。

//////////////原文内容 //////////////////
千年加密解密代码(delphi)

千年加密解密代码....虽然看起来挺复杂的.我是对应汇编的.编译后几乎和游戏客户端里的一样...保证了速度..
二次解密代码我还没去搞.不过一次解密足够了.可以制出很多功能外挂.如自动拾取.吃药.等等...二次解密加密主要用于怪物坐标用的.(自动练功需要解析怪物坐标要用)

声明部分
//二种声方法均可
//const gamestr:string[255] = ‘N>TSVUJlwdcBMFjnAKb?qxvyeGzfLP=_ER@Z\\am]ChgoWD;QuX[<tkpr^`iIHOYs.3" (- ‘+chr(13)+‘<;‘+chr(12)+chr(00)+‘=/!,1>#2$‘+chr(39)+‘89%‘+chr(10)+chr(9)+‘*):5&+67?40‘;
const gamestr : array [0..127] of byte =
($4E, $3E, $54, $53, $56, $55, $4A, $6C, $77, $64, $63, $42, $4D, $46, $6A, $6E, $41, $4B, $62, $3F, $71, $78, $76, $79, $65, $47, $7A, $66, $4C, $50, $3D, $5F, $45, $52, $40, $5A, $5C, $61, $6D, $5D, $43, $68, $67, $6F, $57, $44, $3B, $51, $75, $58, $5B, $3C, $74, $6B, $70, $72, $5E, $60, $69, $49, $48, $4F, $59, $73, $2E, $33, $1E, $01, $13, $22, $10, $0B, $28, $2D, $20, $0D, $19, $3C, $3B, $06, $11, $1C, $0C, $00, $3D, $1D, $2F, $21, $03, $02, $05, $04, $2C, $31, $3E, $23, $32, $24, $27, $38, $1F, $39, $25, $12, $0A, $09, $18, $1B, $2A, $29, $3A, $0E, $35, $07, $26, $0F, $2B, $36, $14, $37, $3F, $34, $30, $16, $08, $15, $17, $1A);

代码部分
function decode (inchar:pchar; len:integer?outchar:pchar):integer; //解密
var
a1, d1: byte;
i, count, di, si :integer;
begin
decode := len div 4 * 3?//返回解密后数据长度
i := 0;
while i < len do
begin
d1 := byte (inchar[i] );
if ( d1 = $3B ) or (d1 = $7A) then
begin
end;
d1 := d1 and $0FF;
d1 := gamestr [d1 + 05]; //d1 := byte ( gamestr [ 1 + d1 ] );
byte (inchar [i] ) := d1; // 根据不同的gamestr数据定义选用不现的方法
inc (i);
end;

di := 0
si := 0?
count := len div 4?//循环次数
for i := 1 to count do
begin
a1 := ord ( inchar [di]); //解密数据 (取4个.转化3个)
a1 := a1 shl 2
d1 := ord ( inchar [di + 1]);
d1 := d1 shr 4
a1 := a1 or d1
outchar[si] := chr (a1);

a1 := ord ( inchar [di + 1]);
a1 := a1 shl 4
d1 := ord ( inchar [di + 2]);
d1 := d1 shr 2
a1 := a1 or d1
outchar[si + 1] := chr (a1);

a1 := ord ( inchar [di + 2]);
a1 := a1 shl 6
d1 := ord ( inchar [di + 3]);
a1 := a1 or d1
outchar[si + 2] := chr (a1);

di := di + 4?
si := si + 3
end;
end;

function encode (inchar:pchar; len:integer?outchar:pchar):integer; //加密
var
a1, d1 :byte;
i,count,di,si :integer;

begin
encode := len div 3 * 4?//返回加密后数据长度
di := 0
si := 0
count := len div 3; //定义循环次数
for i := 1 to count do
begin
a1 := ord ( inchar [di]); //第一次转换 取3个 输出4个
a1 := a1 shr 2
outchar [si] := chr (a1);

a1 := ord (inchar[di]);
a1 := a1 and 3
a1 := a1 shl 4
d1 := ord (inchar[di +1]);
d1 := d1 shr 4
a1 := a1 or d1
outchar[si +1] := chr (a1)

a1 := ord ( inchar[di + 1])
a1 := a1 and $0F
a1 := a1 shl 2
d1 := ord ( inchar[di + 2])
d1 := d1 shr 6
a1 := a1 or d1
outchar[si + 2] := chr (a1);

a1 := ord ( inchar[di + 2])
a1 := a1 and $3F;
outchar[si + 3] := chr (a1)

//第二次转换
d1 := ord ( outchar [si]); //第 1 个
d1 := gamestr [d1];
outchar [si] := chr (d1);

d1 := ord ( outchar [si + 1]); //第 2 个
d1 := gamestr [d1];
outchar [si + 1] := chr (d1);

d1 := ord ( outchar [si + 2 ]); //第 3 个
d1 := gamestr [d1];
outchar [si + 2] := chr (d1);

d1 := ord ( outchar [si + 3]); //第 4 个
d1 := gamestr [d1];
outchar [si + 3] := chr (d1);

di := di + 3
si := si + 4?
end;
end;
网友评论
<