Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. is it possible to have a duplicate uuid generated in vb.net?

is it possible to have a duplicate uuid generated in vb.net?

Scheduled Pinned Locked Moved Visual Basic
csharpquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hansoctantan
    wrote on last edited by
    #1

    is it possible to have a duplicate uuid generated in vb.net?

    MsgBox(Guid.NewGuid().ToString)

    What???

    L M 2 Replies Last reply
    0
    • H hansoctantan

      is it possible to have a duplicate uuid generated in vb.net?

      MsgBox(Guid.NewGuid().ToString)

      What???

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      In theory, yes. In practice, no. Why?

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

      1 Reply Last reply
      0
      • H hansoctantan

        is it possible to have a duplicate uuid generated in vb.net?

        MsgBox(Guid.NewGuid().ToString)

        What???

        M Offline
        M Offline
        Marco Bertschi
        wrote on last edited by
        #3

        A Guid is 128 bit. Therefore you would have to generate 2^128 + 1 GUIDs to encounter a single GUID twice. A thread on StackOverflow.com[^] says that you would need about 10790283070806014188970 years to encounter a single GUID twice, assuming your program does nothing else than creating GUIDs and runs at a processor speed of 1 GhZ, without any interruption by CPU power eaten by other programs or the operating system itself. As you probably can think now, encountering the same GUID twice would be very bad luck and can safely considered as being unrealistic.

        People becoming wiser in order to notice the stupid things they did back in the young days. This doesn't mean that they really stop doing those things. Wise people still do stupid things, only on purpose.

        Richard DeemingR 1 Reply Last reply
        0
        • M Marco Bertschi

          A Guid is 128 bit. Therefore you would have to generate 2^128 + 1 GUIDs to encounter a single GUID twice. A thread on StackOverflow.com[^] says that you would need about 10790283070806014188970 years to encounter a single GUID twice, assuming your program does nothing else than creating GUIDs and runs at a processor speed of 1 GhZ, without any interruption by CPU power eaten by other programs or the operating system itself. As you probably can think now, encountering the same GUID twice would be very bad luck and can safely considered as being unrealistic.

          People becoming wiser in order to notice the stupid things they did back in the young days. This doesn't mean that they really stop doing those things. Wise people still do stupid things, only on purpose.

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          Marco Bertschi wrote:

          Therefore you would have to generate 2^128 + 1 GUIDs to encounter a single GUID twice.

          Not quite. GUIDs aren't entirely random, so you'd only need 2122 to get a collision with a specific GUID. To get a collision anywhere within the set of generated GUIDs, you'd only need to generate around 261 GUIDs. Eric Lippert goes into more detail in part 3 of his GUID guide series[^].


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          M 1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            Marco Bertschi wrote:

            Therefore you would have to generate 2^128 + 1 GUIDs to encounter a single GUID twice.

            Not quite. GUIDs aren't entirely random, so you'd only need 2122 to get a collision with a specific GUID. To get a collision anywhere within the set of generated GUIDs, you'd only need to generate around 261 GUIDs. Eric Lippert goes into more detail in part 3 of his GUID guide series[^].


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            M Offline
            M Offline
            Marco Bertschi
            wrote on last edited by
            #5

            Richard Deeming wrote:

            Not quite. GUIDs aren't entirely random, so you'd only need 2122 to get a collision with a specific GUID. To get a collision anywhere within the set of generated GUIDs, you'd only need to generate around 261 GUIDs.

            Yep - Mark has posted about my brain glitch[^], too.

            People becoming wiser in order to notice the stupid things they did back in the young days. This doesn't mean that they really stop doing those things. Wise people still do stupid things, only on purpose.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups