Hi,
I need help in converting this portion of Delphi codes into PHP. My PHP application is supposed to retrieve an encoded password from the registry (already done so) and then decode the password for use in connecting to a database. The encoded password is stored into the registry by another application which is written in Delphi. To decode the password, I need to use the same encoding key and method as used in the Delphi app. That delphi application has a function called DecodePwd which is used to decoded the encoded passwords. I am trying to convert it into PHP so that my PHP application can correctly decode the password. This portion of the DecodePwd function written in Delphi is giving me headaches in converting to PHP. I wonder if anyone out there will be able to help me solve the problem?
- CODE SNIPPETS START HERE -
.......... Other portion of the codes which I have no problem in converting into PHP ...........
//locate memory
getmem(r,255);
s:=pchar(inSC);
R:= S;
for I := 1 to Length(S) do begin
// decoded
(R+I)^ := char(byte((S+I)) xor (Key shr 8));
// get next key value
Key := (byte((S+I)) + Key) * C1 + C2;
end;
// assigned the terminated char of string
(r+i):=chr(0);
// return the result
result:=string(r);
Would appreciate urgent help from any of you out there.
Thanks.
Rgds,
Sharon