Advertisement
Guest User

decrypt

a guest
Aug 26th, 2012
744
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement