Comparing the hash of a file, containing a list of hashes of multiple files instead of each file, is it good?

27 Views Asked by At

I am writing a Powershell script that accepts a list of files, compresses them in an archive, and then decompresses it to another path.I intend to check if the final extracted files are identical to the input files.

So I started writing a function that calculates the hashes of all files from input, writes them in a CSV file as (Relative Path, Hash) named InputHashes.csv, then does the same for the extracted files and writes them into a separate CSV file named OutputHashes.csv.

By Relative path I mean, if the input path is C:\Files\Data and there is a file with a full path C:\Files\Data\Tests\image.png, The relative path will be the full path, without the input path \Tests\image.png, same for the output files and this makes the paths identical and comparable.

Now I wanted to write the function that cycles each file from the output, checks the relative path in InputHashes.csv and compare the hashes to detect if the output is not the same as the input.

But before that, an idea came into my mind, "Why not just compare the hash of the two InputHashes.csv and OutputHashes.csv file instead of comparing each file one by one?"

Is this a good practice?

My current files list is nearly 8170 and 1.8 GB in size, but it will grow in size and numbers soon.

0

There are 0 best solutions below