Hi
One feature of a program I make is that it allows the user to compare the content of two folders based on hashes. Currently it does this by using stringlists of filenames and hashes. It works OK but I want to make it better - faster, more efficient.
I've looked at TFPHashList which I know is famed for being very fast and it's shortstring limitation is fine for hash algorithms with even SHA512 being 128 hex chars, but I can't quite work out how I can very quickly check if HashListA = HashlistB? Using my current implementation of stringlists, slHashListA contains all the hashes of folderA, and slHashListB contains all the hashes of FolderB. So to compare if one equals the other, I am simply passing slHashListA.Text and slHashlistB.Text to the FPC sha hasher, and comparing the result of the returned hash values. But TFPHashList has no such text property, so I'm curious to know how\if I can say "Is HashListA the same as HashListB?". And although syntacically it seems that the following is OK
HashListA.Add(HashValA, Pointer(HashValA));
HashListB.Add(HashValB, Pointer(HashValB));
if HashListA = HashListB then...
I'm not so sure this is quite the same thing, because in a quick test of 3 files all having the same hash in FolderA and FolderB, it returned false even though all the hashes were the same. I'm guessing this is because each list has a key system, so each value is called by a key. So I guess the keys used in ListA will be different to the keys in ListB? That being the case, how can I quickly check if one matches the other?
There seems to very little documentation or examples for TFPHashList. There's a few threads like this one (
http://forum.lazarus.freepascal.org/index.php/topic,17433.15.html) and there's the official docs (
https://www.freepascal.org/docs-html/fcl/contnrs/tfphashlist.html) but examples are very few. It's hard to get my head round what values are stored in them, and in what form, and how you itterate and compare values in them etc without some basic examples. Does anyone know of any?