I know that you can bang away at GUID generation on single and multiple machines and it's statistically unlikely to ever generate the same GUID twice.
There is lots of information on the internet proving this.
Can the same be said of 100s of Windows CE 4, 5 & 6 devices running applications based on the .NET Compact Framework 3.5 generating GUIDs?
I'm assuming yes but can't find any information proving that the WinCE OS uses random numbers and that they are suitably random.
Can anybody provide such information and references?
Thanks,
J.
Guids are statistically unique. The odds of two different clients generating the same Guid are infinitesimally small (assuming no bugs in the Guid generating code). You may as well worry about your processor glitching due to a cosmic ray and deciding that 2+2=5 today.
How unique is a GUID? 128-bits is big enough and the generation algorithm is unique enough that if 1,000,000,000 GUIDs per second were generated for 1 year the probability of a duplicate would be only 50%. Or if every human on Earth generated 600,000,000 GUIDs there would only be a 50% probability of a duplicate.
The GUID generation algorithm was designed for uniqueness. It was not designed for randomness or for unpredictability. Indeed, if you look at an earlier discussion, you can see that so-called Algorithm 1 is non-random and totally predictable.
GUIDs are quite random, but they are not intended to be used as random numbers - their sole purpose is to uniquely identify entities, so they can be predictable.
From an early article on Guid for the .NET Compact Framework
The .NET Compact Framework team constantly made tradeoffs between the framework footprint size, performance, and implementation time. The full .NET Framework Guid.NewGuid method calls the Windows API function CoCreateGuid that calls UuidCreate to generate globally unique 128-bit numbers. Unfortunately, these functions are not supported on the Pocket PC, so the Guid.NewGuid method was not implemented for the .NET Compact Framework.
This article proposes an algorithm which equals the windows version
It turns out that it's easy to write a custom implementation of the Guid.NewGuid method. The following shows a test application that generates GUIDs on the Pocket PC. It uses a custom class called PocketGuid, that uses the same algorithm as desktop GUIDs and is discussed in more detail later in this paper.
Since 2.0 the actual compact framework contains the Guid.NewGuid
method, I would think they included the mentioned code which results in the same strongness / uniqueness of Guids on WinCE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With