Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why third data in GUID starts with 4?

Tags:

c#

guid

I am generating GUIDs(Global Unique Identifiers) in my project. I saw one similarity among the guids that I have(around 4000) generated, all the guids third data starts with 4. Ex-

ff12e0cf-e541-4463-8a21-ef97842c8847
-------------------^

Why third block always starts with 4?

like image 639
Jainendra Avatar asked Jan 21 '14 13:01

Jainendra


1 Answers

There are different kinds of GUID/UUIDs. You have a bunch of version 4 UUIDs:

http://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29

Version 4 (random)

Version 4 UUIDs use a scheme relying only on random numbers. This algorithm sets the version number (4 bits) as well as two reserved bits. All other bits (the remaining 122 bits) are set using a random or pseudorandom data source. Version 4 UUIDs have the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B (e.g., f47ac10b-58cc-4372-a567-0e02b2c3d479).

like image 109
Joe Avatar answered Nov 18 '22 13:11

Joe