From e04c4c5eb6db16ea378364778f7b25a8366bc16e Mon Sep 17 00:00:00 2001 From: Sebastian Eibl <sebastian.eibl@fau.de> Date: Mon, 8 Apr 2019 17:28:42 +0200 Subject: [PATCH] following standard for random uuids --- src/core/RandomUUID.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/RandomUUID.cpp b/src/core/RandomUUID.cpp index 659922e4f..a2e923398 100644 --- a/src/core/RandomUUID.cpp +++ b/src/core/RandomUUID.cpp @@ -35,6 +35,12 @@ RandomUUID::RandomUUID() std::random_device rd2; std::mt19937 gen2( rd2() ); b_ = dis(gen2); + //unsure how independent these two random numbers really are + + //setting version numbers + //https://en.m.wikipedia.org/wiki/Universally_unique_identifier + a_ = ((a_ & 0xFFFFFFFFFFFF0FFF) | 0x0000000000004000); + b_ = ((b_ & 0x3FFFFFFFFFFFFFFF) | 0x8000000000000000); } RandomUUID::RandomUUID( const UIntType a, const UIntType b) @@ -49,7 +55,7 @@ std::string RandomUUID::toString() const << std::setfill('0') << std::setw(8) << (a_ >> 32) << "-" << std::setw(4) << ((a_&0xFFFFFFFF)>>16) << "-" - << std::setw(4) <<(a_&0xFFFF) << "-" + << std::setw(4) << (a_&0xFFFF) << "-" << std::setw(4) << (b_ >> 48) << "-" << std::setw(12) << (b_&0xFFFFFFFFFFFF); return ss.str(); -- GitLab