(100%) translate these lines of code into PHP
Const XorKey: array [0 .. 7] of Byte = ($ B2, $09, $ AA, $55, $93, $ 6D, $84, $47 ); // function Dec (Str: String): String for String encryption; // What is the character decryption letter? Vari, j: Integer; beginResult: = ''; j: = 0; for I: = 1 to Length (Str) p 2 do begin Result: = Result + Char (StrToInt ('$' + Copy (Str, I * 2-1, 2) xor XorKey [j]); j: = (j + 1) mod 8; end;
Just the above lines of code,
Ask php to help translate this function into php,
I encrypted delphi and decrypted it in php,
I don't know anything about php, but I know how to call it.
Reply to discussion (solution)
Solved 200 points
There is also a post is 100 points: http://bbs.csdn.net/topics/390998635
Give a ciphertext. let me test it ~
Function Dec ($ str) {$ XorKey = array (0xB2, 0x09, 0xAA, 0x55,0x93, 0x6D, 0x84,0x47 ); $ result = ""; for ($ I = 0, $ j = 0; $ I
Can you translate the encryption function as well?
Function Enc (Str: String): String; // character encryption letter? ? Yes ?? Or encryption
Var
I, j: Integer;
Begin
Result: = '';
J: = 0;
For I: = 1 to Length (Str) do
Begin
Result: = Result + IntToHex (Byte (Str [I]) xor XorKey [j], 2 );
J: = (j + 1) mod 8;
End;
End;
Good test ciphertext
Give a ciphertext. let me test it ~
The ciphertext F76DC321A1 should be Edit2, but the php file you translated is that the edited file has one missing
Give a ciphertext. let me test it ~
The ciphertext F76DC321A1 should be Edit2, but the php file you translated is that the edited file has one missing
This is definitely okay.
$ XorKey = array (0xB2, 0x09, 0xAA, 0x55,0x93, 0x6D, 0x84,0x47); echo $ s = enc ('edit2 ', $ XorKey), PHP_EOL; echo dec ($ s, $ XorKey); function Enc ($ Str, $ XorKey) {//: String; // character encryption letter? ? Yes ?? Or encrypt $ Result = ''; $ j = 0; for ($ I = 0; $ I
F76DC321A1
Edit2
Can you translate the encryption function as well?
Function Enc (Str: String): String; // character encryption letter? ? Yes ?? Or encryption
Var
I, j: Integer;
Begin
Result: = '';
J: = 0;
For I: = 1 to Length (Str) do
Begin
Result: = Result + IntToHex (Byte (Str [I]) xor XorKey [j], 2 );
J: = (j + 1) mod 8;
End;
End;
Good test ciphertext
To: xuzuning moderator. I keep making mistakes in your code and don't know why.