[fpc-pascal] MD5 Hash of StringList

Tony Whyman tony.whyman at mccallumwhyman.com
Fri Jul 5 10:43:47 CEST 2019


Be careful, the code below is codepage dependent. TStrings.GetTextStr 
does not inspect the codepage of each string and simply moves the 
characters into a common buffer. Fast, but the question is: are you 
using the hash to compare two string lists that are binary equivalent or 
two string lists that contain the same unicode characters. The code 
below only guarantees to answer the first question.

On 04/07/2019 23:58, Bo Berglund wrote:
> On Thu, 4 Jul 2019 18:13:44 +0200, José Mejuto
> <joshyfun at gmail.com> wrote:
>
>> El 04/07/2019 a las 18:13, James Richters escribió:
>>> Thanks you!
>>>
>>> That got me on the right path.
>>> Here's the working sample:
>>>
>>> Hash  := Md5Print(MD5String(MyStringlist.Text));
>>>
>> Warning! That's platform dependent code due the new line sequences.
> Maybe:
>
> MyStringList.LineBreak := #10;
> Hash  := Md5Print(MD5String(MyStringlist.Text));
>
> Then the new line issue may be solved?
>
>


More information about the fpc-pascal mailing list