This generates a 128-bit Pseudo-Random Unique Identifier (PRNG).
Note: This is different from a Globally Unique IDentifier (GUID) or Universally Unique IDentifier (UUID) as it does not garuntee machine uniqueness.
The measure of randomness is called entropy. Entropy measures how uncertain you are about the value. You can think of entropy as the average number of bits you would need to specify the value if you could use an ideal compression algorithm. The more you know about a value, the smaller its entropy is.
For a distribution with n possible outcomes with probability p1, p2, ..., pn the entropy (H) is
.
For the examples above, first consider a sequence of 128 bits each randomly chosen with equal probability from 0,1. We have n = 2128 possible outcomes each with probability p = 1/n. Substituting these values into the formula we obtain
the number of bits we started with. Now consider the case of a sequence of 16 bytes each chosen randomly only from 0x00 or 0xFF. We have n = 216 possible outcomes, each with probability p = 1/n. This gives entropy H = 16. In other words, the sequence of 128 bits can be encoded (i.e. uniquely represented) by a bitstring of just 16 bits. [Source: http://www.cryptosys.net/rng_algorithms.html]
Although not absolutely unique across machines, the Pseudo-Random Number Generator (PRNG) provides a very high probability of uniqueness on the same machine. Using the 'The Internet Engineering Task Force' URN specification, by adding two variations to the randomly generated values also improves entropy in generation even if the same 16-bit values were produced by the random numbers.
