Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MD5

MD5

Scheduled Pinned Locked Moved C / C++ / MFC
cryptographytutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Ni m
    wrote on last edited by
    #1

    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);

    C 1 Reply Last reply
    0
    • N Ni m

      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);

      C Offline
      C Offline
      cmk
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups