Have a look at this Mersenne Twister random-number generator function that I've written based on what I found on SO.
As I am a beginner and don't understand half of the stuff below, I would very much appreciate if you guided me a little on my journey to improving this random number generator.
I don't need it to be fast, I just want it to be secure.
I want it to be more or less the most secure way of generating numbers.
All that, because I plan on generating random passwords with it later on.
#include <iostream>
#include <random>
unsigned long long int random_integer(unsigned long long int rand_min, unsigned long long int rand_max)
{
// initialize = seed the random device
std::random_device random_device;
// use Mersenne Twister as random-number generator engine
std::mt19937 random_number_generator(random_device());
// number distribution, guaranteed unbiased
std::uniform_int_distribution<int> number_distribution(rand_min, rand_max);
return number_distribution(random_number_generator);
}
int main()
{
for (int i = 1; i <= 10; i++)
{
std::cout << random_integer(1, 1000) << std::endl;
}
return 0;
}
Notes:
I'm on Linux.
Compiler is
g++5
.Standard being C++17.