Good day,
Trust all is well.
I want to duplicate the Move function from Pascal to PHP.
Here is what I have In Pascal:
function Encode(const S: AnsiString): AnsiString;
const
Map: array [0 .. 63] of Char = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
'abcdefghijklmnopqrstuvwxyz0123456789+/';
var
i: LongInt;
begin
i := 0; ;
Move(S[1], i, Length(S));
Result := Map[i mod 64] + Map[(i shr 6) mod 64];
end;
Here is what I have in PHP:
private function Encode($pass)
{
$map = str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/');
$i = 0;
$this->MoveFunction($pass[0], $i, mb_strlen($pass));
$result = $map[$i % 63] . $map[($i >> 6) % 63];
return $result;
}
Now I now know that the Move function is used to copy a section of memory from one place to another, just not sure where to begin and how it would be done. I could not replicate the results from Pascal in PHP. I have tried sub strings ens. to no avail.
I think this is an easy way to test in Pascal:
var
A: array[1..4] of Char;
B: Integer;
begin
A[1] := 'W';
A[2] := 'H';
A[3] := 'A';
A[4] := 'T';
B := 5;
Move(A, B, SizeOf(B));
showmessage(B.ToString()); // 4718679
Any help would be greatly appreciated.
Thank you in advance.