In general for non-named-based guid the 13th digit (right after the second dash) will be a 4 and for named based it will be a 3 or 5.
This isn't universally true but will be for the code you are using.
"0b5415ec-657c-4a80-9199-f7993aff3908"
"275b74ef-e22a-59d6-8b2c-4face1410f59"
The version number is decribed in RFC 4122:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| time_low |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| time_mid | time_hi_and_version |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|clk_seq_hi_res | clk_seq_low | node (0-1) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| node (2-5) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The version number is in the most significant 4 bits of the time stamp
(bits 4 through 7 of the time_hi_and_version field).
The following table lists the currently-defined versions for this UUID variant:
- The time-based version specified in this document.
- DCE Security version, with embedded POSIX UIDs.
- The name-based version specified in this document that uses MD5 hashing.
- The randomly or pseudo-randomly generated version specified in this document.
- The name-based version specified in this document that uses SHA-1 hashing.
With the following code you could check if a GUID
is name-based:
public static bool IsNameBased(Guid id)
{
byte version = GetVersion(id);
return version == 3 || version == 5;
}
public static byte GetVersion(Guid id)
{
byte[] byte_array = id.ToByteArray();
byte version = (byte)(byte_array[7] >> 4);
return version;
}