Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are GUIDs generated on Windows CE devices using the .NET Compact Framework 3.5 still statistically unique?

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.

like image 836
RoboJ1M Avatar asked Jan 19 '12 10:01

RoboJ1M


People also ask

Is GUID guaranteed to be unique?

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 random are GUIDs?

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.

Is GUID truly random?

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.

Are GUIDs 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.


1 Answers

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.

like image 154
Matten Avatar answered Sep 27 '22 15:09

Matten