33#include < cstdarg>
44#include < random>
55#include < sstream>
6+ #include < chrono>
67
78#include " ../sdk/schema.h"
89#include " ../configuration/Configuration.h"
@@ -199,7 +200,7 @@ void PrintTextTable(std::string category, TextTable table)
199200 std::stringstream outputTable;
200201 outputTable << table;
201202 std::vector<std::string> rows = explode (outputTable.str (), " \n " );
202- for (int i = 0 ; i < rows.size () - 1 ; i++)
203+ for (size_t i = 0 ; i < rows.size () - 1 ; i++)
203204 PLUGIN_PRINTF (category, " %s\n " , rows[i].c_str ());
204205}
205206
@@ -222,14 +223,19 @@ std::string str_toupper(std::string s)
222223 return s;
223224}
224225
226+ int32_t genrand ()
227+ {
228+ std::mt19937 rng (std::chrono::steady_clock::now ().time_since_epoch ().count ());
229+ return std::uniform_int_distribution<int >(0 , INT_MAX)(rng);
230+ }
231+
225232std::string get_uuid ()
226233{
227- std::srand (std::time (nullptr ));
228234 return string_format (
229- " %x%x-%x-%x-%x-%x%x%x " ,
230- (rand () & 0xFFFF ), (rand () & 0xFFFF ),
231- (rand () & 0xFFFF ),
232- ((rand () & 0x0fff ) | 0x4000 ),
233- (rand () % 0x3fff + 0x8000 ),
234- (rand () & 0xFFFF ), (rand () & 0xFFFF ), (rand () & 0xFFFF ));
235+ " %04x%04x-%04x-%04x-%04x-%04x%04x%04x " ,
236+ (genrand () & 0xFFFF ), (genrand () & 0xFFFF ),
237+ (genrand () & 0xFFFF ),
238+ ((genrand () & 0x0fff ) | 0x4000 ),
239+ (genrand () % 0x3fff + 0x8000 ),
240+ (genrand () & 0xFFFF ), (genrand () & 0xFFFF ), (genrand () & 0xFFFF ));
235241}
0 commit comments