none
GUID RRS feed

  • Question

  •  

     Hey,

    1. What is the algorithm used by .net framework to create GUID?

    2. Will different systems/applications generate the same GUID? Ex: We have 3 different applications that will create products. GUID is genereated and used as identifier for a product. Application1 created productA with GUID 7ec73574-9ffb-40fb-a9e7-ac90adc52eb8, can Application2 or Application3 generate the same GUID 7ec73574-9ffb-40fb-a9e7-ac90adc52eb8 for a different product? 

    Thanks

    Monday, May 7, 2012 9:55 PM

Answers

  • Depends for what you use GUID (a global unique identifier)

    in .Net is is just a Value Type which you can instance with in pseudo code for all languages

    variable x = Guid.NewGuid

    The purpose is that it is forever unique (although that goal is not for exact 100% reached). 

    So the same Guid is never created.

    But as it is just a value type, there can be used endless times the same guid

    variable y = x


    Success
    Cor


    Tuesday, May 8, 2012 8:38 AM
  • 1. What is the algorithm used by .net framework to create GUID?

    GUID is generated based on the machine's MAC address and DateTime. I think, the algorthm to generate GUID is not publisehed by microsoft (which may introduce security issues otherwise).

    2. Will different systems/applications generate the same GUID? Ex: We have 3 different applications that will create products. GUID is genereated and used as identifier for a product. Application1 created productA with GUID 7ec73574-9ffb-40fb-a9e7-ac90adc52eb8, can Application2 or Application3 generate the same GUID 7ec73574-9ffb-40fb-a9e7-ac90adc52eb8 for a different product? 

    Yes. There can be duplicates.. but that is extremely rare. The following two stack overflow discussions speak about the uniqueness of GUIDs.

    http://stackoverflow.com/questions/39771/is-a-guid-unique-100-of-the-time

    http://stackoverflow.com/questions/1705008/simple-proof-that-guid-is-not-unique

    I hope this helps.


    Please mark this post as answer if it solved your problem. Happy Programming!

    Tuesday, May 8, 2012 8:39 AM

All replies

  • For answers like these, Google is your friend.  If you have googled, then I'll try to answer to the best of my ability.

    1.  Not sure.  Decompiling didn't help me figure it out :(

    2.  With the implementation of the Guid structure, it is guaranteed to be GLOBALLY unique across "all computers and networks", MSDN Library 2008 - Guid Structure.

    Monday, May 7, 2012 10:07 PM
  • You can read the post in Eric Lippert blog about GUIDs. That will open up the secrets behind.

    GUID guide, part 1

    GUID guide, part 2

    GUID guide, part 3


    • Edited by MasaSam Tuesday, May 8, 2012 4:49 AM
    Tuesday, May 8, 2012 4:48 AM
  • Depends for what you use GUID (a global unique identifier)

    in .Net is is just a Value Type which you can instance with in pseudo code for all languages

    variable x = Guid.NewGuid

    The purpose is that it is forever unique (although that goal is not for exact 100% reached). 

    So the same Guid is never created.

    But as it is just a value type, there can be used endless times the same guid

    variable y = x


    Success
    Cor


    Tuesday, May 8, 2012 8:38 AM
  • 1. What is the algorithm used by .net framework to create GUID?

    GUID is generated based on the machine's MAC address and DateTime. I think, the algorthm to generate GUID is not publisehed by microsoft (which may introduce security issues otherwise).

    2. Will different systems/applications generate the same GUID? Ex: We have 3 different applications that will create products. GUID is genereated and used as identifier for a product. Application1 created productA with GUID 7ec73574-9ffb-40fb-a9e7-ac90adc52eb8, can Application2 or Application3 generate the same GUID 7ec73574-9ffb-40fb-a9e7-ac90adc52eb8 for a different product? 

    Yes. There can be duplicates.. but that is extremely rare. The following two stack overflow discussions speak about the uniqueness of GUIDs.

    http://stackoverflow.com/questions/39771/is-a-guid-unique-100-of-the-time

    http://stackoverflow.com/questions/1705008/simple-proof-that-guid-is-not-unique

    I hope this helps.


    Please mark this post as answer if it solved your problem. Happy Programming!

    Tuesday, May 8, 2012 8:39 AM