MCPcopy Create free account
hub / github.com/cinit/TMoe / randomUuid

Method randomUuid

app/src/main/cpp/utils/Uuid.cpp:10–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include "Uuid.h"
9
10std::string Uuid::randomUuid() {
11 std::random_device rd;
12 std::mt19937 gen(rd());
13 std::uniform_int_distribution dis(0, 15);
14 std::uniform_int_distribution dis2(8, 11);
15 std::stringstream ss;
16 int i;
17 ss << std::hex;
18 for (i = 0; i < 8; i++) {
19 ss << dis(gen);
20 }
21 ss << "-";
22 for (i = 0; i < 4; i++) {
23 ss << dis(gen);
24 }
25 ss << "-4";
26 for (i = 0; i < 3; i++) {
27 ss << dis(gen);
28 }
29 ss << "-";
30 ss << dis2(gen);
31 for (i = 0; i < 3; i++) {
32 ss << dis(gen);
33 }
34 ss << "-";
35 for (i = 0; i < 12; i++) {
36 ss << dis(gen);
37 }
38 return ss.str();
39}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected