Generating a random bit - lack of randomness in C rand()

后端 未结 4 1696
礼貌的吻别
礼貌的吻别 2020-11-30 14:13

I am using rand() to generate either 0 or 1 (rand() % 2). I am seeding it using the current time (srand(time(NULL))).

After mu

4条回答
  •  眼角桃花
    2020-11-30 14:48

    I'd suggest using a better RNG. You're running on Windows so you can use rand_s: It's a Microsoft extension that uses the Windows cryptographic RNG.

提交回复
热议问题