This is a part of my program:

Code:long long int expand(long long int part) { HCRYPTPROV hCryptProv = NULL; LPCWSTR UserName = L"My"; BYTE add[8] = {0}; if(!(CryptAcquireContextW(&hCryptProv, UserName, 0, PROV_RSA_FULL, 0))) { CryptAcquireContextW(&hCryptProv, UserName, 0, PROV_RSA_FULL, CRYPT_NEWKEYSET); } CryptGenRandom(hCryptProv, 4, add); part |= ((long long int)add[0] << 56) + ((long long int)add[1] << 48) + ((long long int)add[2] << 40) + ((long long int)add[3] << 32); CryptReleaseContext(hCryptProv, 0); return part; } int main() { long long int my = expand(100); //100 example number printf("%lli\n", my); printf("%lli\n", expand(100)); //100 example number fflush(NULL); getchar(); return 0; }

There are two problem:

The two functions printf return different values and on each execution this program always return the same values.

Any suggestions?