Guide versus random string

If I arbitrarily create a 32-character string, can I use this string as a GUID for all purposes and tasks?

Will generating a โ€œGUIDโ€ have a more or less collision probability than a โ€œrealโ€ GUID?

Any specific information about the GUID and how they are compared with random strings is evaluated.

+7
source share
6 answers

GUID generation algorithms take date and time into account, and also generate random numbers to create the final 128-bit value.

If you simply generate random strings without any other algorithmic algorithms, then yes, you will face a much greater risk of collision. (Computers cannot generate truly random numbers, so other data should be collapsed into GUID generation algorithms to reduce the risk of collision. For example, GUID v1 used the MAC address of the computer, although this approach is outdated since it identifies the generating computer.)

You can create your own GUID value, but why invent something that already works well?

Also see Eric Lippert 's answer about why using a GUID is superior to using a native random machine generator for home computers.

+4
source

A GUID is not a 32-character long string. No, you cannot use it instead of a GUID.

Depending on the encoding, char can be one or two bytes, so 32 characters can be 32 bytes or 64 bytes. GUID - 16 bytes. If you have an equivalent amount of randomness in the generator, your string will give less chance of a collision. Saying that the probability of a collision of 16 bytes is unlikely, as it is.

A clinch is that you must have at least a generator like the Guid generator to make it useful. When you do, stock it.

+3
source

Depending on the GUID with which you are comparing this: currently most GUIDs are โ€œVersion 4โ€, which is actually just a big random number with some bits lost. Thus, while the random number generator is no worse than the one used to generate the GUID, your solution is more unique.

If this is Version 1 GUID, then it is probably more unique than a random number (assuming that it is used as expected: the system clock is not reset very often, the system has a network card, and the MAC address has not been changed), but most people no longer use version 1 because it is a leak of your MAC address.

+2
source

It depends on the algorithm you will use. If you have a good generator, the result will be the same.

The probability depends on how good both generators are (yours against a GUID one).

+1
source

I would suggest using factual recommendations. The chances that your random string generator will be unique are far less than guid's.

+1
source

Social MSDN provides little information, but does not answer your question whether a chance of a collision is more likely or not. Guid Structure says the GUID is not a string, but "The GUID is a 128-bit integer (16 bytes) that can be used on all computers and networks that require a unique identifier. Such an identifier has a very low chance of duplication."

0
source

All Articles