vendredi 1 novembre 2019

How can we make std::uniform_int_distribution cryptographically secure?

In C++, how can we make std::uniform_int_distribution cryptographically secure? For example is the following code generate cryptographically secure uniformly random numbers? If not, how can we correct it?

#include <iostream>
#include <random>

int main(void){
  std::default_random_engine generator;
  std::uniform_int_distribution<int> distribution(0,9);
  int p[10]={};

  for (int i=0; i<10; ++i) {
    int number = distribution(generator);
    ++p[number];
  }
}



Aucun commentaire:

Enregistrer un commentaire