The GUID is a 16-byte (128-bit) number. The most
commonly used structure of the data type is:
| Bits |
Bytes |
Description |
| 32 |
4 |
Data1 |
| 16 |
2 |
Data2 |
| 16 |
2 |
Data3 |
| 64 |
8 |
Data4 |
Except for Data4, the most significant byte in
every field is stored last; Data4 stores all bytes
consecutively.
One to three of the most significant bits of the
second byte in Data 4 define the type variant of the
GUID:
| Pattern |
Description |
| 000 |
Network Computing System backward
compatibility |
| 100 |
Standard |
| 110 |
Microsoft Component Object Model
backward compatibility; this includes the
GUID's for important interfaces like
IUnknown and IDispatch. |
| 111 |
Reserved for future use. |
The most significant four bits of Data3 define
the version number, and the algorithm used.
Text encoding
Guids are most commonly written in text as a
sequence of hexadecimal digits such as:
- 3F2504E0-4F89-11D3-9A0C-0305E82C3301
This text notation contains the following fields,
separated by hyphens:
| Hex digits |
Description |
| 8 |
Data1 |
| 4 |
Data2 |
| 4 |
Data3 |
| 4 |
Initial two bytes from Data4 |
| 12 |
Remaining six bytes from Data4 |
For the first three fields, the most significant
digit is on the left. The last two fields are
treated as eight separate bytes, each having their
most significant digit on the left, and they follow
each other from left to right. Note that the digit
order of the fourth field may be unexpected, since
it's treated differently than in the structure.
Often braces are added to enclose the above
format, as such:
- {3F2504E0-4F89-11D3-9A0C-0305E82C3301}
When printing fewer characters is desired, GUIDs
are sometimes encoded into a base64 or Ascii85
string. Base64-encoded GUID consists of 22 to 24
characters (depending on padding), for instance:
- 7QDBkvCA1+B9K/U0vrQx1A
- 7QDBkvCA1+B9K/U0vrQx1A==
and Ascii85 encoding gives only 20 characters, e.
g.:
- 5:$Hj:Pf\4RLB9%kU\Lj