From 12e8f194218e1867629c0053bab3351dea327753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Mon, 20 Feb 2023 20:05:26 +0100 Subject: [PATCH] Add comments explaining UUID generation --- src/engine/shared/uuid_manager.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/engine/shared/uuid_manager.cpp b/src/engine/shared/uuid_manager.cpp index 7bc3bccc5..d9b0bc8e0 100644 --- a/src/engine/shared/uuid_manager.cpp +++ b/src/engine/shared/uuid_manager.cpp @@ -15,8 +15,11 @@ CUuid RandomUuid() CUuid Result; secure_random_fill(&Result, sizeof(Result)); + // set version 4 (UUID is randomly generated) Result.m_aData[6] &= 0x0f; Result.m_aData[6] |= 0x40; + + // set variant 1 (RFC 4122) Result.m_aData[8] &= 0x3f; Result.m_aData[8] |= 0x80; @@ -38,10 +41,14 @@ CUuid CalculateUuid(const char *pName) Result.m_aData[i] = Digest.data[i]; } + // set version 3 (UUID is generated by MD5 hashing a namespace identifier and a name) Result.m_aData[6] &= 0x0f; Result.m_aData[6] |= 0x30; + + // set variant 1 (RFC 4122) Result.m_aData[8] &= 0x3f; Result.m_aData[8] |= 0x80; + return Result; }