HI . Having a problem with creating MD5 hash on linux

HI . Having a problem with creating MD5 hash on linux
problem is with the use of pansichar at its replacement.
this is the problem code

procedure TMD5.Update(const Input: string);
var
{$IFDEF UNICODE}
utf8Str: UTF8String;
{$ENDIF}
Bytes: TByteDynArray;
Len: Integer;
Str: PAnsiChar;
begin
{$IFDEF UNICODE}
utf8Str := UTF8Encode(Input);
Len := Length(utf8Str);
{$ELSE}
Len := Length(Input);
{$ENDIF}
if Len > 0 then
begin
SetLength(Bytes, Len);
{$IFDEF UNICODE}
Str := PAnsiChar(utf8Str);
{$ELSE}
Str := PAnsiChar(Input);
{$ENDIF}
Move(Str^, Pointer(Bytes)^, Len);
Update(Bytes, Len);
end;
end;

from MessageDigest_5.pas
I have tried replacing pansichar with pwidechar
but I get a different result
help appreciated :)
thanks!

Comments

  1. David Heffernan ThashMD5.gethashbytes/string. Should accept tbytes instead. At least in 10.2 they added tstream, before strings were the only way

    ReplyDelete
  2. Eugene Kotlyarov with my question, I specifically had the Delphi team in mind.

    ReplyDelete
  3. Eugene Kotlyarov Yeah, there are loads of methods there that are a mess. Who knows which encoding is used. UTF16 I guess. This whole thing winds me up so much. Delphi and PHP, brothers in arms.

    ReplyDelete

Post a Comment