Fun with GUIDs *** Geek Topic Advisory ***

by Elsewhere 22 Replies latest jw friends

  • Elsewhere

    Recently I worked on a DB File Storage System that saved files under GUID ID's. I became curious what the odds were of the DB accidentally generating a duplicate GUID for two different files, so I did the math.

    Here is what I found:

    Number of Possible 128bit GUIDs:340,282,366,920,938,000,000,000,000,000,000,000,000

    Number of seconds in the age of the universe (15 billion years)

    (Divide the first number by the second to get GUIDs per Second)

    Number of GUIDs generated per second for life of universe:71,887,518,854,221

    What this means is that we would need a battery of computers working 24/7 generating 71.9 quadrillion GUIDs per second for the entire life of the universe before we would find a duplicate GUID.

    I get the feeling we don’t need to worry about duplicate GUIDs.

  • EscapedLifer1

    I love acronyms. What the heck is a GUID in your field? In my field, it stands for Graphical User Interface Device(or sometimes Display).

    I wonder how many duplicate acronyms there are?


  • Elsewhere

    GUID: Guaranteed Unique ID

    There are a few who call it: Globally Unique Identifier

    A GUID is a randomly generated 128 bit number. Because it is randomly generated, one has to wonder what the odds are that the same GUID would be generated twice... this is why I did the math.

    Oh, and I'm a programmer. We use GUIDs to give ID's to items that cannot have IDs in sequential order (1, 2, 3, 4, 5...), which is why we use random numbers (4234, 6743, 2345, 7234, 3466, etc...) .

  • tetrapod.sapien

    what random number generator do you use?

  • Elsewhere

    I normally use C# and all we need to do is execute the following code:


    Here is a sample of what a GUID looks like: a3482b66-4e0d-46d3-9e2c-3939c215731b

    You'll notice there are letters mixed in there. This is because computers use a number system called Hexdecimal. The number system you learned in school is called Decimal and has ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

    Hexdecimal has 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f

    Here is an example:

    Decimal addition:
    7564 + 235 = 7799

    Hexdecimal addition:
    1D8C + EB = 1E77

    The two math problems are the same and are adding the same values, only represented in decimal and hexdecimal.

  • tetrapod.sapien

    yes, i know about different number systems.

    so, the C# compiler comes with a random number generator? do you have the code for the actual number generator in the compiler (Mono)? or are you using the compiler that comes with the .NET Framework SDK?


  • Elsewhere

    The GUID generator comes as a part of the .NET framework.

    If you are looking for the actual code for generating a GUID, you can download a sample project from:

    This is written in VB6 because there is no need to write one in C# since the framework creates GUIDs for you.

  • seattleniceguy

    Elsewhere, from what I understand, GUIDs are not actually random. They are based on several unique properties of your hardware, such as your MAC address, which automatically uniquifies the GUID to your particular box, so we can rule out duplicates by any other system in the universe. Then, the time at the moment of GUID generation plays a role, so we can rule out duplicates by your box at any other moment in time. And finally, I think it is uniquified further by a random element, which uniquifies the GUID within the smallest unit of time granularity for the system clock.

    But it's funny that you posted this because I was just thinking about posting a question on the same topic. Because GUIDs are not random, I wonder if it would be possible to predict other GUIDs created by the same box within a particular time frame. That is, if we know GUID A was produced on a particular box on a particular date, is it possible to predict a namespace of other GUIDs that that box would produce?

    Because the namespace is so large, I tend to think that it is not feasible. Does anyone else know anything about this?


  • Elsewhere

    It is true that at one time GUIDs were based on a PC's MAC address. In time people started to worry about privacy issues and Microsoft removed the MAC address component. This privacy hole was used when locating the creator of the Melissa worm (His worm contained a GUID that pointed straight to his PC -- dumbass ).

    A very interesting read can be found here:

    If you want your brain to go numb, you can read the technical standards used to create GUIDs here:

  • seattleniceguy

    Hmm...interesting. It's weird that they took the MAC address out altogether, though. They could have hashed it and still achieved the same effect of guaranteeing uniqueness. Then again, the hash results would have been too long, I suppose. Thanks for the info!


Share this