Click here to Skip to main content
15,885,032 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to initialize array of variable length? Pin
Le@rner19-Jan-14 22:47
Le@rner19-Jan-14 22:47 
Questionhelp me to generate MD5 of Binary hash value. Pin
Le@rner26-Dec-13 21:33
Le@rner26-Dec-13 21:33 
AnswerRe: help me to generate MD5 of Binary hash value. Pin
Richard MacCutchan26-Dec-13 22:25
mveRichard MacCutchan26-Dec-13 22:25 
GeneralRe: help me to generate MD5 of Binary hash value. Pin
Le@rner26-Dec-13 23:45
Le@rner26-Dec-13 23:45 
GeneralRe: help me to generate MD5 of Binary hash value. Pin
Richard MacCutchan27-Dec-13 0:08
mveRichard MacCutchan27-Dec-13 0:08 
GeneralRe: help me to generate MD5 of Binary hash value. Pin
Le@rner27-Dec-13 2:03
Le@rner27-Dec-13 2:03 
GeneralRe: help me to generate MD5 of Binary hash value. Pin
Richard MacCutchan27-Dec-13 3:26
mveRichard MacCutchan27-Dec-13 3:26 
GeneralRe: help me to generate MD5 of Binary hash value. Pin
Randor 27-Dec-13 10:51
professional Randor 27-Dec-13 10:51 
Hi,

Hope you had a great Christmas holiday. Could not help but notice that '680065006c006c006f00' is an array of BYTE representing the unicode version of the string 'hello'. You can easily do this:

C++
//Various #includes...
#define LENGTH 16

int _tmain(int argc, _TCHAR* argv[])
{
	HCRYPTPROV p = 0;
	HCRYPTHASH h = 0;
	DWORD dwError=0;
	if(CryptAcquireContext(&p,NULL,NULL,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT))
	{
			DWORD length = LENGTH;
			BYTE md5[LENGTH];
			BYTE buf[LENGTH];
			if(CryptCreateHash(p,CALG_MD5, 0, 0, &h))
			{
				wsprintfW((LPWSTR)buf,L"hello");
				if(CryptHashData(h, buf, wcslen((LPWSTR)buf) * sizeof(WCHAR), 0))
				{
					if(0 == dwError && CryptGetHashParam(h, HP_HASHVAL, md5, &length, 0))
					{
						std::cout << std::setfill('0');
						std::for_each(md5,md5+LENGTH,
										[](BYTE b)
										{
											std::cout << std::setw(2) << std::hex << static_cast<int>(b);
										});
						std::cout << std::endl;
					}
				}
			}
	}
	return 0;
}


Output: fd186dd49a16b1bf2bd2f44e495e14c9

Best Wishes,
-David Delaune
GeneralRe: help me to generate MD5 of Binary hash value. Pin
Le@rner27-Dec-13 17:30
Le@rner27-Dec-13 17:30 
QuestionPointers in C/C++ Pin
tgsb26-Dec-13 20:24
tgsb26-Dec-13 20:24 
AnswerRe: Pointers in C/C++ Pin
Richard MacCutchan26-Dec-13 22:23
mveRichard MacCutchan26-Dec-13 22:23 
AnswerRe: Pointers in C/C++ Pin
jschell27-Dec-13 12:54
jschell27-Dec-13 12:54 
JokeRe: Pointers in C/C++ Pin
enhzflep4-Jan-14 8:26
enhzflep4-Jan-14 8:26 
QuestionXML parsing in QT Pin
Utheen26-Dec-13 16:44
Utheen26-Dec-13 16:44 
AnswerRe: XML parsing in QT Pin
Albert Holguin27-Dec-13 4:20
professionalAlbert Holguin27-Dec-13 4:20 
GeneralRe: XML parsing in QT Pin
Utheen29-Dec-13 20:48
Utheen29-Dec-13 20:48 
AnswerRe: XML parsing in QT Pin
Albert Holguin30-Dec-13 7:05
professionalAlbert Holguin30-Dec-13 7:05 
QuestionDynamically updating image (PNG) Pin
Don Guy26-Dec-13 12:53
Don Guy26-Dec-13 12:53 
AnswerRe: Dynamically updating image (PNG) Pin
Albert Holguin26-Dec-13 15:25
professionalAlbert Holguin26-Dec-13 15:25 
Questionhow to know file type and its protection type for office files? Pin
Le@rner24-Dec-13 1:22
Le@rner24-Dec-13 1:22 
SuggestionRe: how to know file type and its protection type for office files? Pin
Richard MacCutchan24-Dec-13 4:23
mveRichard MacCutchan24-Dec-13 4:23 
GeneralRe: how to know file type and its protection type for office files? Pin
Le@rner25-Dec-13 18:23
Le@rner25-Dec-13 18:23 
GeneralRe: how to know file type and its protection type for office files? Pin
Richard MacCutchan25-Dec-13 23:57
mveRichard MacCutchan25-Dec-13 23:57 
QuestionDirectShow - video resize interpolation Pin
sdancer7523-Dec-13 22:09
sdancer7523-Dec-13 22:09 
AnswerRe: DirectShow - video resize interpolation Pin
sdancer757-Jan-14 23:20
sdancer757-Jan-14 23:20 

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.