Click here to Skip to main content
15,884,986 members
Articles / All Topics

Checksum Program That Actually Works

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
8 Nov 2014Apache1 min read 11.6K   6   2
Simple checksum program that allows to verify file authenticity

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!

This article was originally posted at http://www.ikriv.com/blog?p=1541

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


Written By
Technical Lead Thomson Reuters
United States United States
Ivan is a hands-on software architect/technical lead working for Thomson Reuters in the New York City area. At present I am mostly building complex multi-threaded WPF application for the financial sector, but I am also interested in cloud computing, web development, mobile development, etc.

Please visit my web site: www.ikriv.com.

Comments and Discussions

 
Suggestiontoo much code in Main() - Method Pin
sx20088-Nov-14 5:37
sx20088-Nov-14 5:37 
GeneralRe: too much code in Main() - Method Pin
Ivan Krivyakov8-Nov-14 7:57
Ivan Krivyakov8-Nov-14 7:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.