MD5
-
how to get hash from BYTE *pass to HCRYPTHASH hHash using CryptCreateHash and CryptHashData //in this program hash doesn't change =( HCRYPTPROV hCryptProv; CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0); HCRYPTHASH hHash; CryptCreateHash(hCryptProv,CALG_MD5, 0, 0, &hHash); CryptHashData(hHash,pass,strlen(fPass)+1,0);
-
how to get hash from BYTE *pass to HCRYPTHASH hHash using CryptCreateHash and CryptHashData //in this program hash doesn't change =( HCRYPTPROV hCryptProv; CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0); HCRYPTHASH hHash; CryptCreateHash(hCryptProv,CALG_MD5, 0, 0, &hHash); CryptHashData(hHash,pass,strlen(fPass)+1,0);
You're just missing the final step. 1. Get a CSP handle - CryptAcquireContext() 2. Create a hash object and specify hash algorithm - CryptCreateHash() 3. Add data to hash - CryptHashData() or CryptHashSessionKey() 4. Keep doing 3 until added all data 5. Finish hash and get result : ::CryptGetHashParam(hnd, HP_HASHVAL, BUFF, &BUFFLEN, 0); // BUFF is hash value or, ::CryptSignHash(hnd, T, NULL, F, BUFF, &BUFFLEN); // BUFF is result signature or, ::CryptVerifySignature(hnd, BUFF, BUFFLEN, pub, NULL, F); // BUFF is signature to verify Each of these functions will finish the hash (i.e. add any algorithm required padding), meaning that any subsequent calls to CryptHashData() or CryptHashSessionKey() will fail. However, you can call any of these 3 multiple times safely, the hash is only 'finished' (padded) once. ...cmk Save the whales - collect the whole set