Home > Net >  Turn the Delphi c #
Turn the Delphi c #

Time:10-13

 function UnEncryptString (Source, Key: string) : string; 
Var
KeyLen: integer;
KeyPos: integer;
Offset: integer;
Dest: string;
SrcPos: integer;
SrcAsc: integer;
TmpSrcAsc: integer;
The begin
KeyLen:=Length (Key);
If KeyLen=0 then
Key:='Delphi';
KeyPos:=0;
Offset:=strtoint (' $' + copy (Source, 1, 2));
SrcPos:=3;
Repeat
SrcAsc:=strtoint (' $' + copy (Source, SrcPos, 2));
If KeyPos & lt; KeyLen then
KeyPos:=KeyPos + 1
The else
KeyPos:=1;
TmpSrcAsc:=SrcAsc xor word (Key [KeyPos]);
If TmpSrcAsc & lt;=Offset then
TmpSrcAsc:=255 + TmpSrcAsc - Offset
The else
TmpSrcAsc:=TmpSrcAsc - Offset;
The Dest: Dest=+ CRH (TmpSrcAsc);
Offset:=SrcAsc;
SrcPos:=SrcPos + 2;
Until SrcPos & gt;=Length (Source);
Result:=Dest;
end;

CodePudding user response:

The step that you can't write,,,, repeat until SrcPos & gt;=Length (Source); Can be changed to c # while (SrcPos & gt;=Length (Source))

CodePudding user response:

Every c # doesn't understand Delphi. To find out the meaning of the keyword to control

CodePudding user response:

Public string UnEncryptString (string Source, the string Key)
{
Int KeyLen KeyPos, Offset, SrcPos SrcAsc, TmpSrcAsc;
String Dest="";
KeyLen=Key. Length;
If (KeyLen==0)
Key="Delphi".
KeyPos=0;
Offset=int. Parse (Source. The Substring (0, 2));
SrcPos=3;
Do
{
SrcAsc=int. Parse (Source. The Substring (SrcPos, 2));
If (KeyPos & lt; KeyLen)
KeyPos=KeyPos + 1;
The else
KeyPos=1;
TmpSrcAsc=SrcAsc ^ (int) (Key [KeyPos]);
If (TmpSrcAsc & lt;=Offset)
TmpSrcAsc=255 + TmpSrcAsc - Offset;
The else
TmpSrcAsc=TmpSrcAsc - Offset;
Dest=Dest + (TmpSrcAsc - 48). The ToString ();
Offset=SrcAsc;
SrcPos=SrcPos + 2;
} while (SrcPos & gt;=Source. Length);
Return the Dest;
}
Turn to you for my original used Delphi, verify,
  •  Tags:  
  • C #
  • Related