add MD5 to my MFC Application

I would like to  MD5 hashing ability to a dialog box application I created with MFC.
The source code is freely available from langfin but I would like to borrow only the relevant classes and then use them
in my dialog box application .
Is there anyway I can do this?
Who is Participating?
Jaime OlivaresConnect With a Mentor Software ArchitectCommented:
You can use Windows' CryptoAPI:

Or you can use an independent one:
samroycAuthor Commented:
How can I use the Windows Crypto API to hae the MD5 hash of an entiire file instead of a string?I tried to point to a file,but
it simply assumes that "filename" is a string.Any help would be greatly appreciated.
Jaime OlivaresSoftware ArchitectCommented:
Look at the first article, the most recent comment solves your problem, you must process block by block, that is, you have to read file into a proper sized buffer, let's say, every 4000 bytes, and use md5 functions to partially calculate hash, continue until read last block in file (notice last block could be smaller than 4000 bytes).
Have a look to:
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

samroycAuthor Commented:
I am inexperienced so I dont know how I would write that as MFC class.
Also  there is  no "wincrypt.h" in the header file?
langfine has this page
where in a static library  is built for doing the MD5 there no way to "attach"the correct files,and then
call the functions from my application?
Thank you  
Jaime OlivaresSoftware ArchitectCommented:
yes, you can attach MD5Checksum.h,  MD5Checksum.cpp and MD5ChecksumDefines.h into your own project, no need to build a library, I think.
samroycAuthor Commented:
I manually copied MDCheckSum.h MD5CheckSum.cpp and MD5CheckSumDefines.h into my project.I am getting compiler errors
when I try to get my appliation to use the functions from this class.
This is what I tried-
Included "name_of_dialog.h" file in MD5CheckSum.cpp
Then added a variable m_pWnd of type CDialog* in MD5CheckSum class
Added a function void SetParent(CDiaog*,pWnd)
And then tried to edit this function with
I get error C2653-CMD5CheckSum is not a class
I'd appreciate any help with this.
Jaime OlivaresSoftware ArchitectCommented:
>Included "name_of_dialog.h" file in MD5CheckSum.cpp
This is not a good practice. Better you can put a CMD5CheckSum object as a dialog member (inside your dialog.h class). You will need to include "CMD5CheckSum.h" in your_dialog.h.
Then, you can use in some dialog's function at your_dialog.cpp

All Courses

From novice to tech pro — start learning today.