Is there a way to distinguish a GUID from a random number?

The ability to distinguish GUIDs from random data can be useful when debugging hidden code defects.

On Windows, each GUID created has version 4, so it has "4" as the first nibble of the third part. Therefore, if a 16-byte sequence violates this rule, it is not GUID version 4. For example,

567E1ECB-EA1C-42D3-A3ED-87A5D824D167 

may be either version 4 GUID or something else, but

 567E1ECB-EA1C-02D3-A3ED-87A5D824D167 //third section starts with 0, not with 4 

not a GUID version 4.

What other signs of a 16-byte memory block are or are not a valid GUID?

+6
debugging undefined-behavior guid random
Nov 20 '09 at 15:55
source share
2 answers

GUIDs are hexadecimal, so you can check which characters are included (ie "X", "Y", etc. are invalid)

Check out Wikipedia for a definition, and you could probably find more ideas there.

http://en.wikipedia.org/wiki/Globally_Unique_Identifier

+1
Nov 20 '09 at 15:58
source share

Besides the GUID version (0100), there is also something called the GUID variant. This will be 2 bits (10) in octet 8. The remaining bits a of the v4 GUID are, by definition, random.

+1
Nov 23 '09 at 14:51
source share



All Articles