★帮我翻译几行delphi的代码,不胜感激!在线等
哪位高手能帮忙将下边myenctstr函数翻译成C#版,小弟不胜感激!
function myenctstr(const s:string; skey:string):string;
var
i,j: integer;
hexS,hexskey,midS,tmpstr:string;
a,b,c:byte;
begin
hexS :=myStrtoHex(s);
hexskey:=myStrtoHex(skey);
midS :=hexS;
for i:=1 to (length(hexskey) div 2) do
begin
if i <> 1 then midS:= tmpstr;
tmpstr:= ' ';
for j:=1 to (length(midS) div 2) do
begin
a:=strtoint( '$ '+midS[2*j-1]+midS[2*j]);
b:=strtoint( '$ '+hexskey[2*i-1]+hexskey[2*i]);
c:=a xor b;
tmpstr := tmpstr+myStrtoHex(chr(c));
end;
end;
result := tmpstr;
end;
function mydectstr(const s:string; skey:string):string;
var
i,j: integer;
hexS,hexskey,midS,tmpstr:string;
a,b,c:byte;
begin
hexS :=s;//应该是该字符串
if length(hexS) mod 2=1 then
begin
showmessage( '密文错误! ');
exit;
end;
hexskey:=myStrtoHex(skey);
tmpstr :=hexS;
midS :=hexS;
for i:=(length(hexskey) div 2) downto 1 do
begin
if i <> (length(hexskey) div 2) then midS:= tmpstr;
tmpstr:= ' ';
for j:=1 to (length(midS) div 2) do
begin
a:=strtoint( '$ '+midS[2*j-1]+midS[2*j]);
b:=strtoint( '$ '+hexskey[2*i-1]+hexskey[2*i]);
c:=a xor b;
tmpstr := tmpstr+myStrtoHex(chr(c));