What is a unique code? How to create it?

Hello everyone, I have asked this question several times on the forum. But I can’t quite figure it out. Are there tools that help you create one unique code for multiple applications?

A unique code is a GUID (Microsoft) or a UUID (generic). There’s no other difference between the two.

Here is how to create them: https://www.arungudelli.com/tutorial/javascript/how-to-create-uuid-guid-in-javascript-with-examples/

1 Like

this sentence confuses me.


It depends on the requirement that the codes be unique. Theoretically it is unlikely to ensure that a code is unique unless you have all other instances of the codes. Something like a GUID is large enough and is designed to make it likely to be unique but they are not guaranteed to be unique. Probably part of the reason it is difficult to get answers is that the question is very general.

Getting a unique code might be the same thing as generating a random number. You could do something such as use a set of 64 characters; whatever number of characters you want. Then use a random number generator to generate as number of characters as you need. A GUID or UUID would be something like that. I think they use 16 (hexadecimal) characters. You could generate byte values (values 0 to 255) and then use base 64 to convert the bytes to something humans can use. Email messages convert the bytes in mages to base-64.

There are many ways to do it. That is part of the reason it is difficult to find answers.