Click here to Skip to main content
Licence 
First Posted 29 Aug 2002
Views 143,397
Bookmarked 52 times

Use Windows Crypto API to calculate a MD5 string.

By | 29 Aug 2002 | Article
Use Windows Crypto API to calculate a MD5 string.

Introduction

The source code demonstrates how to invoke the Windows Crypto API to calculate a MD5 string.

The MD5 Message-Digest Algorithm is described in Internet RFC 132.

The sample uses the class Cmd5Capi, a very simple MFC class to wrap the standard win api necesary calls.

Includes required

#include <wincrypt.h> // Cryptographic API Prototypes and Definitions

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Victor M. Valenzuela

Web Developer

Spain Spain

Member

Now, I works for Aurigae S.A a spanish services enterprise, specialized on information technologies for critical mission applications, mainly in the areas of payment system management, stock trading and telecommunications.


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralThanks PinmemberAsaf G0:05 6 May '08  
QuestionHow to decrypt data? Pinmemberivax0:49 4 Oct '05  
AnswerRe: How to decrypt data? PinmemberJohn A. Johnson0:06 26 Oct '05  
GeneralA better solution : here is the code PinmemberElmue10:43 22 Apr '04  
GeneralRe: A better solution : here is the code PinmemberHughJampton6:11 25 Apr '05  
GeneralRe: A better solution : here is the code PinsussAnonymous12:32 25 Apr '05  
GeneralRe: A better solution : here is the code PinmemberHughJampton15:00 25 Apr '05  
GeneralExcellent code - one simple modification PinmemberDouglas R. Keesler15:41 5 Jun '05  
GeneralRe: A better solution : here is the code Pinmemberpscholl6:01 6 Jun '08  
GeneralRe: A better solution : here is the code PinmemberElmue14:40 6 Jun '08  
GeneralProblem with this constructor. PinmemberMr.Prakash16:28 20 Jan '04  
GeneralCompile Error ! Pinmemberfreedem15:00 2 Dec '03  
GeneralRe: Compile Error ! PinmemberVictor M. Valenzuela21:28 2 Dec '03  
GeneralRe: Compile Error ! PinmemberMihai Moga20:44 29 Mar '06  
GeneralRe: Compile Error ! Pinmemberbahram_cho20:42 6 Apr '07  
Generalcompilation Errors Pinmemberrohitgad7:40 24 Sep '03  
GeneralRe: compilation Errors PinmemberVinayak9:54 16 Jun '04  
GeneralRe: compilation Errors PinmemberScott B.18:59 21 Mar '06  
GeneralDifferent Output PinmemberAtif Goheer16:42 5 Aug '03  
GeneralRe: Different Output Pinmemberqihongbo22:04 28 Sep '03  
GeneralThanks PinmemberPaul Hooper14:40 25 Apr '03  
GeneralCrypto.h PinsussAnonymous3:15 4 Nov '02  
GeneralRe: Crypto.h PinmemberStefan-Mihai MOGA0:49 27 Jun '05  
GeneralNeeds improvements PinmemberVagif Abilov2:46 30 Aug '02  
There are several improvements that both article and code need:
 
1. More careful code packaging. It's not enough to ZIP all files in the directory. You end up with some temporary files included in the package. Remember that the more compact is solution, the more elegant it looks. In your package there are about 200 KB of files included. However, 3 largest files (with extension NCB, OPT and APS) are intermediate files that occupy about 150 KB (75%!) of space and are not part of the project. You should examine source files before including them into a package.
 
2. Better C++ coding. Let's take as an example the following method:
 
CString &Cmd5Capi::Digest(CString & csBuffer)
 
Why is buffer declared as "CString&" and "const CString&" (or even "LPCTSTR")? It should not be modified by the method. The same goes for return value. Why is it "CString&" and not "const CString&"?
 
3. The method digest might as well be declared as static, so MD5 digest could be computed without allocating an instance of Cmd5Capi class.
 
However, it's a good attempt for a first article.
 
Best regards
 
Vagif Abilov
MCP (Visual C++)
Oslo, Norway

 
If you're in a war, instead of throwing a hand grenade at the enemy, throw one of those small pumpkins. Maybe it'll make everyone think how stupid war is, and while they are thinking, you can throw a real grenade at them.
Jack Handey, Deep Thoughts

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

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120604.1 | Last Updated 30 Aug 2002
Article Copyright 2002 by Victor M. Valenzuela
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid