Score:0

Windows Equivalent to `sha256sum -c` (cryptographic hash, digest file, recursive integrity check, SHA256SUMS)

cn flag

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?

Michael Altfield avatar
cn flag
See also https://stackoverflow.com/questions/72087842/windows-equivalent-to-sha256sum-c-cryptographic-hash-digest-file-recursive
Michael Altfield avatar
cn flag
See also https://superuser.com/questions/1719053/windows-equivalent-to-sha256sum-c-cryptographic-hash-digest-file-recursive
Michael Altfield avatar
cn flag
See also https://askubuntu.com/questions/1091335/create-checksum-sha256-of-all-files-and-directories
dcom-launch avatar
cn flag
well the command to hash a file via powershell is: `get-filehash -algorithm sha256 filename` I'll leave writing the one liner / few line script to do what you need to do as an exercise to the reader.
Michael Altfield avatar
cn flag
See also https://superuser.com/questions/1315365/how-can-i-generate-an-md5-sum-for-a-folder-on-windows
Score:1
cn flag

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"
Michael Altfield avatar
cn flag
That's a great option! Unfortunately it looks like the catalog file is a binary file. I was hoping for something that would be a bit more cross-platform. If it were plaintext (even with a different encoding than on Linux), I could at least generate the digest (catalog?) file on Linux.
Score:1
eu flag

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.

Michael Altfield avatar
cn flag
Thanks for the suggestions! Can you include usage examples (including the command typed and the output) in your answer, similar to was shown in the question?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.