请帮忙将delphi代码转换成C#的写法(200)

N

nfsong

Unregistered / Unconfirmed
GUEST, unregistred user!
XorKey:array[0..7] of Byte=($B2,$09,$AA,$55,$93,$6D,$84,$47);
//字符串加密用Function Decserial(Str:string):string;Stdcall;//注册字符解密函數vari,j:Integer;
begin
Result:='';
j:=0;
for i:=1 to Length(Str) div 2do
begin
Result:=Result+char(StrToInt('$'+Copy(Str,i*2-1,2)) xor XorKey[j]);
j:=(j+1) mod 8;
end;
end;
Function Encserial(Str:String):String;Stdcall;//字符加密函數vari,j:Integer;
begin
Result:='';
j:=0;
for i:=1 to Length(Str)do
begin
Result:=Result+IntToHex(Byte(Str) xor XorKey[j],2);
j:=(j+1) mod 8;
end;
end;
请帮忙将delphi代码转换成C#的写法初学C#,不知道delphi的数据类型和C#的数据类型是怎样对应的。
 
A

augur

Unregistered / Unconfirmed
GUEST, unregistred user!
C#自己有加密算法.
 
Z

znxia

Unregistered / Unconfirmed
GUEST, unregistred user!
为了怕别人破解他数据,所以才自己写加密算法。不过上面代码真的不复杂,会C#语法的就应该可以转化,我不会C#,帮你顶一下吧。
 

草原骏马

Unregistered / Unconfirmed
GUEST, unregistred user!
自己写的加密算法,更容易破解。还是用系统的或比较好的现成的加密算法。只要掌握好密钥,就没有问题。中国人民银行的金融加密算法用的都是Des。我是懒得替你翻译了。
 
L

lollman

Unregistered / Unconfirmed
GUEST, unregistred user!
static byte[] XorKey ={ 0xB2, 0x09, 0xAA, 0x55, 0x93, 0x6D, 0x84, 0x47 };
static string Decserial(string Str) { int j;
j = 0;
byte[] bytes;
bytes = new byte[Str.Length / 2];
string Result = "";
char ch;
for (int i = 0;
i < (Str.Length / 2);
i++) { bytes = byte.Parse(Str.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber);
ch=(char)(bytes ^ XorKey[j]);
Result = Result + ch;
j = (j + 1) % 8;
} return Result;
} static string Encserial(string Str) { int j = 0;
string Result = "";
int ss;
for (int i = 0;
i < Str.Length;
i++) { ss = Str ^ XorKey[j];
Result = Result + ss.ToString("X2");
j = (j + 1) % 8;
} return Result;
}
 

Similar threads

I
回复
0
查看
754
import
I
I
回复
0
查看
597
import
I
I
回复
0
查看
548
import
I
I
回复
0
查看
693
import
I
I
回复
0
查看
507
import
I
顶部