How to generate an MD5 hash of a file from your program with wodCrypt ActiveX DLL

For a copy of the sample project please
click here
to download and install the product evaluation.
Introduction
This solution demonstrates how wodCrypt will quickly and easily generate an MD5 hash for a specified file. wodCrypt is a lightweight component that provides strong encryption for your applications. Whenever you need to secure your transactions, wodCrypt's cryptography can be used. It provides support for most common crypto algorithms .
Detail
Our demonstration code illustrates a case in which we take a local file, and use it to calculate it's MD5 hash. The whole process is done in three simple steps.
Setup
Download and run the executable from the above link. The samples will
be placed in directory C:\Program Files\WeOnlyDo.Com\Crypt\Samples.
There are example projects for C#, VB, ASP, Delphi, VC and VBS.
In the VB6 project, add a reference to wodCryptCOM
and event handlers are provided by the development environment.
In C#, wodCrypt is referenced as WODCRYPTCOMLib, and
the all the necessary code is in the Form_Load Event.
VB6
Dim wodCrypt As wodCryptCom
Dim InFile As FileBlob
Dim hash As FileBlob
Set wodCrypt = New wodCryptCom
Set InFile = New FileBlob
Set hash = New FileBlob
C#
WODCRYPTCOMLib.wodCryptCom wodCrypt = new WODCRYPTCOMLib.wodCryptCom();
WODCRYPTCOMLib.FileBlobClass InFile = new WODCRYPTCOMLib.FileBlobClass();
WODCRYPTCOMLib.FileBlobClass hash = new WODCRYPTCOMLib.FileBlobClass();
The first step is to declare and initialize the objects that we will
use to achieve our goal. The code shown above does that.
The settings
In order to successfully calculate an MD5 hash we need to point
our component to the file for which a hash is to be calculated, and set its digest to MD5:
VB6
InFile.FileName = "c:\windows\notepad.exe"
wodCrypt.Type = MD5
C#
InFile.Filename = @"C:\Windows\notepad.exe";
wodCrypt.Type = WODCRYPTCOMLib.CryptoTypes.MD5;
The Final step
Once we have selected the file to calculate, and set the digest we want to use,
we can perform the actual calculation.
VB6
wodCrypt.Digest InFile, hash
MsgBox hash.ToHex
C#
wodCrypt.Digest((WODCRYPTCOMLib.Blob)InFile,(WODCRYPTCOMLib.Blob)hash);
MessageBox.Show(hash.ToHex());
The calculation is done in one method, Digest, and the
calculated value is stored into a special WODCRYPTCOMLib.Blob object called "hash". The
application will then show the result in a message box window using the ToHex() method of the hash object.
Summary
This simple demonstration shows an easy way to calculate hash values
in three simple steps using wodCrypt to do the calculations for you.
For more sophisticated examples please follow the link below:
Visit
WeOnlyDo! Inc.
for more information and more samples.