DWORD rnd(DWORD n) { HCRYPTPROV p; DWORD r; //乱数初期化 CryptAcquireContext(&p, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); //乱数生成 CryptGenRandom(p, sizeof(r), (BYTE*)&r); //解放 CryptReleaseContext(p, NULL); return r%n; }
DWORD rnd(DWORD n) { HCRYPTPROV p; DWORD r; //乱数初期化 CryptAcquireContext(&p, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); //乱数生成 CryptGenRandom(p, sizeof(r), (BYTE*)&r); //解放 CryptReleaseContext(p, NULL); return r%n; }