I'm actualy trying to convert pascal code into c# code (we are re-writing old application).
Pascal code:
function DecryptStr(Source: PChar): string;
var
st: string;
i, k, mask: byte;
begin
Result := '';
try
SetString(st, Source, 32);
if st[1] <> #0 then
begin
mask := ord(st[1]);
k := ord(st[2]) xor mask;
SetLength(Result, k);
for i := 1 to k do
begin
inc(mask);
k := ord(st[i + 2]) xor mask;
Result[i] := chr(k);
// Result := Result + chr(k);
end;
end;
except
end;
end;
And my C# code:
public static string decrypt(string hash)
{ string buffer;
byte i, k, mask;
string result = "";
buffer = hash.Substring(0, 32);
mask = (byte)(buffer[0]);
k = (byte)((byte)(buffer[1])^mask);
for (i = 0; i<k-1; i++)
{
mask += 1;
k = (byte)((byte)(buffer[i+2])^mask);
result+=(char)(k);
}
// string decoded = System.
return (result);
}
Please, tell me, is it similar or pascal got some hidden stuff?
Example: input in c#:
акРЖђЏГ€€њљђНѓGН q6™&і—'n1•\›ЛH[
output in c#:
\u0011$\f\v&\t\b
But it doesnt look like the real password. Please, advice me what is going wrong.