I test with Delphi10. xxHash32Calc('aa') or xxHash64Calc('aa')
compared to a javascript lib, will get different result.
the following modification will get same result.
{$IFNDEF FPC}
uses System.SysUtils;
{$ENDIF}
function xxHash32Calc(const AString: string; ASeed: LongWord): LongWord;
begin
Result := xxHash32Calc({$IFNDEF FPC}TEncoding.UTF8.GetBytes{$ELSE} PChar {$ENDIF}(AString), length(AString), ASeed);
end;
function xxHash64Calc(const AString: string; ASeed: QWord): QWord;
begin
Result := xxHash64Calc({$IFNDEF FPC}TEncoding.UTF8.GetBytes{$ELSE} PChar {$ENDIF} (AString), length(AString), ASeed);
end;
xxHash.pas
I test with Delphi10. xxHash32Calc('aa') or xxHash64Calc('aa') compared to a javascript lib, will get different result.
the following modification will get same result.
{$IFNDEF FPC} uses System.SysUtils; {$ENDIF}
function xxHash32Calc(const AString: string; ASeed: LongWord): LongWord; begin Result := xxHash32Calc({$IFNDEF FPC}TEncoding.UTF8.GetBytes{$ELSE} PChar {$ENDIF}(AString), length(AString), ASeed); end;
function xxHash64Calc(const AString: string; ASeed: QWord): QWord; begin Result := xxHash64Calc({$IFNDEF FPC}TEncoding.UTF8.GetBytes{$ELSE} PChar {$ENDIF} (AString), length(AString), ASeed); end;