Often, when I download files from the Internet, I need to verify the checksum. That is, calculate actual checksum of the file and make sure it matches the expected value. I used checksum calculator from Codeplex, but I could not make it compare checksums for me; -c
option simply did not work as advertised. Finally, I decided to write my own version that takes a file, an algorithm, and an expected checksum, and gives me a simple go-no-go answer. You can find it on GitHub.
Usage instructions are very simple:
USAGE: checksum algorithm file [expectedValue]
Supported algorithms: MD5, SHA1, SHA256, SHA384, SHA512
Some examples:
C:\ivan\dev\proj\Checksum> checksum SHA1 checksum.exe
54e579387a43b578d971e1d090b8043b94396b69
C:\ivan\dev\proj\Checksum> checksum SHA1 checksum.exe 54e579387a43b578d971e1d090b8043b94396b69
54e579387a43b578d971e1d090b8043b94396b69
SHA1 checksum is valid
C:\ivan\dev\proj\Checksum> checksum SHA1 checksum.exe 54e579387a43b578d971e1d090b8043b94396b6A
54e579387a43b578d971e1d090b8043b94396b69
SHA1 checksum is NOT VALID!!!
Checksum calculator verifies other programs, so it must be open source and free of any backdoors. I provide full source code (Checksum.cs), which is relatively short. .NET Framework already has classes for checksum calculation, so all I needed to write was a command line parser.
.NET Framework also comes with built-in C# compiler, so you don’t have to use my binaries. You can easily compile the source on any Windows machine using one-line compile.bat. Visual Studio is not required. All you need is .NET Framework 2.0 or higher. It comes out of the box with Windows Vista and above, and even if you have Windows XP, you most likely have it installed.
Happy checksumming!
CodeProject