tags:

views:

540

answers:

7

I am wondering, what goes into the creation of a GUID. I don't mean what is used to create a GUID in a specific language (NewID() in SQL, new GUID() in C#), I mean when you call those methods/functions, what do they do to make the GUID?

+2  A: 

The details of GUIDs, including the algorithm used to generate them is described on wikipedia.

Rob Walker
A: 

Hash function. Its complicated.

http://en.wikipedia.org/wiki/GUID#Algorithm Knows more than I do.

Kent Fredric
+1  A: 

Are you looking for something more than Wikipedia?

Karg
+2  A: 

Also, RFC 4122 (which is referenced in the Wikipedia article) describes how GUIDs should be built.

Michael Burr
+1  A: 

Raymond Chen has a great explanation of how they work

John Sheehan
That is a good article, but it is versio 1 of GUID creation which no one should be using anymore.
EBGreen
A: 

A word of caution that a very great deal of what you read on the Internet about GUID creation may well be wrong, or at least out of date for your specific platform.

I once single-stepped through a heap of Windows code to settle an argument about GUID creation on WinXP. Unfortunately, it turned out that I was wrong (i.e. I lost the argument), but so was Larry Osterman, so I felt slightly better about it.

Will Dean
A: 

In short, it's not complicated at all. GUID (or UUID) Version 4 (current) is a partially random number, plain and simple (122 out of 128 bits are random, the rest are used for storing version and revision). The trick is that the possible values of this number are so many that the probability of a hit is for most practical purposes, zero.

Sklivvz
I would say that it is a partially random number. Some parts of it are not random at all.
EBGreen