[英]Can I generate cryptographically secure random data from a combination of random_device and mt19937 with reseeding?
[英]mt19937 can't set random_device
我的代碼無法識別“生成器”,但我在 C++ 文件的頂部聲明了它。 我需要它是線程安全的,所以我用“thread_local”聲明它:
#include <windows.h>
#include <iostream>
#include <random>
using namespace std;
thread_local mt19937 generator;
DWORD GenerateRandomNumber(DWORD dwMin, DWORD dwMax)
{
uniform_int_distribution <DWORD> distribution(dwMin, dwMax);
return distribution(generator);
}
int main()
{
random_device rd;
generator(rd());
}
mt19937::operator()
不帶參數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.