#define key 123
#define C1 52845 
#define C2 22719CString CCrypt::Decrypt(CString S, WORD Key)
{
CString Result,str;
int i,j;
Result.Empty();
for(i=0;i<S.GetLength()/2;i++)
{
j=((BYTE)S.GetAt(2*i)-65)*26;
j+=(BYTE)S.GetAt(2*i+1)-65;
str="1";
str.SetAt(0,j);
Result+=str;
}
S=Result;
for(i=0;i<S.GetLength();i++)
{
Result.SetAt(i,(BYTE)S.GetAt(i)^(Key>>8));
Key=((BYTE)S.GetAt(i)+Key)*C1+C2;
}
return Result; 
哪位高手能把这段函数转化成delphi啊?

解决方案 »

  1.   

    获取去DELPH板块更容易得到答复。
      

  2.   

    理解逻辑了,然后就是看Dephi如何实现了..
      

  3.   

    用VC编译成DLL,Dephi调用就可以了!
      

  4.   

    哪位大大能帮忙做成delphi能调用的dll啊,通过后立刻给分!可以加我QQ8472939
      

  5.   

    const
      C1 = 52845;
      C2 = 22719;function TForm1.Decrypt(srcPchar: pchar; key: WORD): String;
    var
      i,j: Integer;
      strTmp: String;
      aryTmp: array of Byte;
    begin
      strTmp := '';
      for i := 0 to (length(srcPchar) div 2 - 1) do
      begin
        j := (Byte(srcPchar[2*i]) - 65) * 26;
        j := j + Byte(srcPchar[2*i + 1]) - 65;
        strTmp := strTmp + string(char(j));
      end;
      srcPchar := pchar(strTmp);
      SetLength(aryTmp,length(srcPchar));
      for i := 0 to (length(srcPchar) - 1) do
      begin
        aryTmp[i] := byte(srcPchar[i]);
      end;  for i := 0 to (length(srcPchar) - 1) do
      begin
        strTmp[i + 1] := char(aryTmp[i] xor (key shr 8));
        Key := (aryTmp[i] + Key) * C1 + C2;
      end;
      Result := strTmp;
    end;// 用法
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      ShowMessage(Decrypt(pchar('dsklkjfdsklj'),125));
    end;
      

  6.   

    分呢,楼主,我昨天看完变型2写到后半夜才写完,测过了,没问题那个#define key 123 和Decrypt(CString S, WORD Key)  第2个参数相同,我没给你加,