1

What is the equivalent to sha256sum -c in Windows?

I have a set of very important files that I need to copy-to and mirror across many different types of disks in many geographically distinct locations. After relaying the contents to disk via USB, ethernet, fiber, radio, telegram, and signal fires (some of which are more reliable means of transmissions than others!), I want to check the integrity of the data written to disk.

In Debian Linux, file checksums are typically stored in a SHA256SUM "digest" file that's generated using the sha256sum command. It's trivial to use this command to generate this file with the recursive SHA256 checksums of all the files in the current directory and subdirectories. It's also very trivial for the user to use this command to verify the integrity of all the files, recursively. For example, consider this super-critical dataset of cat pictures

user@disp3274:~/Pictures$ tree
.
├── cats
│   ├── cat1.jpeg
│   ├── cat2.jpeg
│   └── cat3.jpeg
└── people
    ├── person1.jpeg
    └── person2.jpeg

2 directories, 5 files user@disp3274:~/Pictures$

I can generate the checksum file as follows

user@disp3274:~/Pictures$ time sha256sum `find . -type f` > SHA256SUMS

real 0m0.010s user 0m0.008s sys 0m0.002s user@disp3274:~/Pictures$

user@disp3274:~/Pictures$ cat SHA256SUMS b2d82e7b8dcbaef4d06466bee3486c12467ce5882e2eabe735319a90606f206a ./people/person2.jpeg e01f7b240f300ce629c07502639a670d9665e82df6cba9311b87ba3ad23c595d ./people/person1.jpeg 53e056cc91fd4157880fb746255a2f621ebee8ca6351a659130d6228142c1e47 ./cats/cat1.jpeg a0a73a21b9d26f1bbe4fcfce0acd21964dedf2dc247a5fe99bd9f304aa137379 ./cats/cat2.jpeg a171fa88d431a531960b6eb312d964ed66cc35afd64bde5dda9b929ad83343f6 ./cats/cat3.jpeg user@disp3274:~/Pictures$

And I can verify the integrity of all the files as follows

user@disp3274:~/Pictures$ time sha256sum -c SHA256SUMS 
./people/person2.jpeg: OK
./people/person1.jpeg: OK
./cats/cat1.jpeg: OK
./cats/cat2.jpeg: OK
./cats/cat3.jpeg: OK

real 0m0.009s user 0m0.008s sys 0m0.000s user@disp3274:~/Pictures$

In Windows, what is the equivalent built-in tool for generating a SHA256SUMS (or similar digest file using another cryptographic hash function) and verifying the integrity of a set of files, recursively?

2 Answers2

1

New-FileCatalog and Test-FileCatalog can do this.

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/new-filecatalog?view=powershell-7.2

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/test-filecatalog?view=powershell-7.2

New-FileCatalog -Path "x:\DirectoryName" -CatalogFilePath "x:\SomeOtherDirectoryName\"

Test-FileCatalog -Path "x:\DirectoryName" -CatalogFilePath "x:\SomeOtherDirectoryName\catalog.cat"

Greg Askew
  • 39,132
1

I use fsum. https://www.slavasoft.com/fsum/ Faster, but has problems with different codepages.

Another one is exf https://www.exactfile.com/exf/ Slower but understands codepages.

Andre
  • 11
  • 1