18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-21 13:15:02 +01:00

Improve random engine entropy and clean up random engine initialization

This commit is contained in:
2026-09-14 19:26:24 +02:00
parent 1c2f397fc5
commit 788135cc2d
4 changed files with 23 additions and 13 deletions

View File

@@ -7,6 +7,7 @@
#include <algorithm>
#include <cstdint>
#include "utilities/utilities.h"
#include "utilities/Globals.h"
class UID {
public:
@@ -14,10 +15,9 @@ public:
static UID random() {
static thread_local std::mt19937_64 gen{clock_seed()};
UID u;
uint64_t a = gen();
uint64_t b = gen();
uint64_t a = Global.random_engine();
uint64_t b = Global.random_engine();
for (int i = 0; i < 8; ++i) u.bytes[i] = uint8_t(a >> (i * 8) & 0xFF);
for (int i = 0; i < 8; ++i) u.bytes[8 + i] = uint8_t(b >> (i * 8) & 0xFF);