Wednesday, May 27, 2020

Is GUID Unique guarantee?

In short: Yes.


GUID stands for Globally Unique Identifier. The name literally means when you randomly generate a new GUID value, it will be a new unique ID globally that no one ever created.


But is it actually that unique?


This is a sample of a GUID: 123e4567-e89b-12d3-a456-426614174000
Sometimes, it is shorten to 123e4567e89b12d3a456426614174000


GUID is a 128-bit number, has 36 characters includes 32 hexadecimal characters and 4 hyphens.


There are several versions (or types) of GUID:
- Version 1: Date time and MAC address
- Version 2: Date time and MAC address, DCE security version (improved V1)
- Version 3: MD5 hash & namespace
- Version 4: Random
- Version 5: SHA-1 hash & namespace (similar to V3)


Version 1 and 2 are mostly used as unique identifier for network cards.
Version 3 and 5 are mostly used as hashing (credentials) value in security software. But recently, SHA-1 became crackable, so it is no longer a trusted way to hash the credential value. SHA-256 or above would be a better choice of hashing.
Version 4 is most well-known and widely used as an Unique Identifier for data records in software programming in general.


So, what is the chance of "GUID collision"?
GUID is finite. It means there is a chance of an actual collision, in theory.
If a GUID is generated using Version 1 or 2, it is not possible except there is error in implementation.
If a GUID is generated using Version 4, it uses 4 bits to indicate version 4, and 2 or 3 bits to indicate the variant, that leaves it 122 bits to randomly generate the GUID value. So, there are total of 2^122, or 5.3×10^36 (5.3 undecillion) possible version-4 variant-1 UUIDs


This is a so large pool of variants that the chance of collision is so small or considered as ignorable in real life.


There are many examples to describe how big it is:

  • The number of random version-4 UUIDs which need to be generated in order to have a 50% probability of at least one collision is 2.71 quintillion which is equivalent to generating 1 billion UUIDs per second for about 85 years.
  • Consider the observable universe, which contains about 5×1022 stars; every star could then have 6.8×1015 universally unique GUIDs.
  • You probably wont run out - there's about 75,000,000,000,000,000,000 grains of sand on earth but even that pales in comparision to the number of GUIDs available: 340,282,366,920,938,463,463,374,607,431,770,000,000

Tiền lương và thuế thu nhập cá nhân ở Đức

Cũng giống như nhiều nước phát triển ở Châu Âu, chính phủ Đức đã dày công đưa nước Đức tiến tới một xã hội mà ở đó, người dân được quan tâm ...