Hello all,

I need to verify files MD5, SHA1 ,SHA256, etc. hashes using Excel/VBA. I will have all files in a given folder and need to loop each file and get its hash. I will compare this value to the hash the site the file came from claims it should be. In greater context I download a bunch of offline installers for various programs and need to verify their hashes against the hash given by the website. I am not interested in getting Excel/VBA to compare for me, only in getting the hash from the file.

Outside of VBA, I could use the following cmd command to do this:

CertUtil -hashfile fullpath\filename.ext hashtype
IE:
CertUtil -hashfile C:\myfiles\myfile.exe SHA256
the resulting string returned by the above command is what I need.

Bonus points if we can do this as a function I can use in cell, something like 'GetHashSHA256(Path, Filename)' or 'GetHash(Path, Filename, Type)' where 'Type' = SHA256, MD5, etc.

Double bonus for including links to documentation for the method you use.

What I have so far is this: https://en.wikibooks.org/wiki/Visual...Hashing_in_VBA

I get the automation error as it seems to require a specific version of .NET which isnt an option for me. I have Win 7 and Excel 2016 (not O365). For what its worth I am a fan of late binding and prefer not to have to reference libraries if possible to avoid.

I am not including a sample as whats on sheet doesn't really matter, its just VBA and getting the result. Feel free to hard code the filename and path, place it in a cell, prompt, etc. The result can be a msgbox, debug.print, in a cell, etc. However its done, as long as the returned hashes are correct, I can re-purpose it to work the way I need.

Thanks