fSeedA = 56789 ;/// 常量 ,
fSeedB = 54667 ; /// 常量 ,
fKey=7744 ; // 钥匙
function Decrypt(const str: string): string;
var
i, j, iKey: Integer;
strGet: string;
begin
strGet := str;
iKey := FKey;
Result := '';
for i := 1 to (Length(strGet) div 2) do
begin
j := (Integer(strGet[2*i-1])-65)*26;
j := j + (Integer(strGet[2*i])-65);
Result := Result + Char(j);
end;
strGet := Result;
for i := 1 to Length(strGet) do
begin
Result[i] := Char(byte(strGet[I]) xor (iKey shr 8));
iKey := (Byte(strGet[I]) + iKey) * FSeedA + FSeedB;
end;
end; 以上是在网上看到的一段用DELPHI写的解密的函数,加密的类似,所以想请各位帮看看如何转到VC++中,这里我最不理解的是返回值是string类型,那么在VC中可以用哪种类型替代呢?
另外,绝色字体处,for中1开始循环,不是一般从0开始么?
没接触过DELPHI,还请各位大侠指点,不胜感激!
fSeedB = 54667 ; /// 常量 ,
fKey=7744 ; // 钥匙
function Decrypt(const str: string): string;
var
i, j, iKey: Integer;
strGet: string;
begin
strGet := str;
iKey := FKey;
Result := '';
for i := 1 to (Length(strGet) div 2) do
begin
j := (Integer(strGet[2*i-1])-65)*26;
j := j + (Integer(strGet[2*i])-65);
Result := Result + Char(j);
end;
strGet := Result;
for i := 1 to Length(strGet) do
begin
Result[i] := Char(byte(strGet[I]) xor (iKey shr 8));
iKey := (Byte(strGet[I]) + iKey) * FSeedA + FSeedB;
end;
end; 以上是在网上看到的一段用DELPHI写的解密的函数,加密的类似,所以想请各位帮看看如何转到VC++中,这里我最不理解的是返回值是string类型,那么在VC中可以用哪种类型替代呢?
另外,绝色字体处,for中1开始循环,不是一般从0开始么?
没接触过DELPHI,还请各位大侠指点,不胜感激!
VC的FOR循环也可能从1开始循环
pchar(string) 可强制转换成C的char*
VC的 CString 是从0 开始计数的
只是,strGet[2*i-1]有这么一句,我在VC中可不好模拟啊!
我是不是需要模拟一个它这样的字符串,第一位表示长度,第二位以后才是数据?
那么如果数据过长的话,第一位也存储不过来呀!
这是这个算法本身就有的局限还是?
晕晕的,呵呵!大家继续给点意见啊