rand
#include <wincrypt.h>
void f(){
HCRYPTPROV hProv = 0;
// Get a handle to the default PROV_RSA_FULL provider.
if(!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
printf("Error %x during CryptAcquireContext!\n", GetLastError());
return;
}
if(!CryptGenRandom(hProv, 8, pbData))
//CryptGenRandom(hProv, len, b)
// Release the provider handle.
if(!CryptReleaseContext(hProv, 0))
{ printf("Error %x during CryptReleaseContext!\n", GetLastError()); return; }
}
#pragma comment (lib, "crypt32.lib")
Cryptapi.lib
https://blog.csdn.net/iteye_15337/article/details/82249461
{ //what openssl does
BYTE buf[64];
/* poll the CryptoAPI PRNG */
/* The CryptoAPI returns sizeof(buf) bytes of randomness */
if (CryptAcquireContextW(&hProvider, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT)) {
if (CryptGenRandom(hProvider, sizeof(buf), buf))
RAND_add(buf, sizeof(buf), sizeof(buf));
CryptReleaseContext(hProvider, 0);
}
}