mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
Merge #6348
6348: Add comments explaining UUID generation r=Chairn a=Robyt3 ## Checklist - [ ] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
commit
d4e2c2f7a4
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue