Click here to Skip to main content
11,928,078 members (48,335 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


7 bookmarked

A Simple Hash Tool

, 16 Jan 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
A tool to generate MD5 and SHA-1 checksums.

Sample Image


This is my second article on CodeProject. Here I am demonstrating a tool to generate MD5 and SHA-1 checksums.

Using the code

You can use an executable directly. To edit code, you can import it in Visual Studio.

Points of Interest

To compute the hash of large files, the ComputeHash function cannot be directly used since the application will go unresponsive for large files.

To prevent this from happening, a hash is generated in another thread using a BackgroundWorker.

// When user clicks to generate MD5 of a file

private void button5_Click(object sender, EventArgs e) {
    getFileMD5.DoWork += new DoWorkEventHandler(MD5_DoWork);
    getFileMD5.RunWorkerCompleted += new RunWorkerCompletedEventHandler(MD5_Completed);

// Function to generate MD5 of a file

public void MD5_DoWork(object sender, DoWorkEventArgs e) {
    while((readCount = stream.Read(buffer, 0, bufferSize)) > 0) {
        algorithm.TransformBlock(buffer, 0, readCount, buffer, 0);
        progressBar1.Invoke((MethodInvoker)delegate() {    			
            if(progressBar1.Value < progressBar1.Maximum)
                progressBar1.Value += 1;
                progressBar1.Value = 0;

// To be called when job is done, Clear progress-bar and copy result to clipboard
public void MD5_Completed(object sender, RunWorkerCompletedEventArgs e){
    textBox5.Text = ((string)e.Result).ToLowerInvariant();

About this project

This tool I have written for my personal use and wanted to share with others. If it proves to be of any help, please let me know.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Anurag Saini
India India
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 Pin
Ali Taghvajou22-Jan-13 0:45
memberAli Taghvajou22-Jan-13 0:45 
GeneralMy vote of 5 Pin
shajimon21-Jan-13 17:33
membershajimon21-Jan-13 17:33 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151126.1 | Last Updated 16 Jan 2013
Article Copyright 2013 by Anurag Saini
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid