Guest User

decrypt

a guest
Aug 26th, 2012
356
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void decrypt(LPBYTE data, DWORD size, LPSTR key, DWORD algo)
  2. {
  3.     HCRYPTPROV hProv;
  4.     CryptAcquireContext(&hProv, 0, 0, PROV_RSA_AES, CRYPT_VERIFYCONTEXT);
  5.  
  6.     HCRYPTHASH hHash;
  7.  
  8.     CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash);
  9.     CryptHashData(hHash, (LPBYTE)key, strlen(key), CRYPT_USERDATA);
  10.    
  11.     HCRYPTKEY hkey;
  12.  
  13.     CryptDeriveKey(hProv, algo, hHash, CRYPT_EXPORTABLE , &hkey);
  14.  
  15.     CryptDecrypt(hkey, NULL, TRUE, 0, data, &size);
  16.  
  17.  
  18.     CryptDestroyHash(hHash);
  19.  
  20.     CryptReleaseContext(hProv, 0);
  21.  
  22. }
RAW Paste Data