Home > Back-end >  The only serial number generation problems is not connected to the case
The only serial number generation problems is not connected to the case

Time:04-30

Produced a string of with the serial number of the uniqueness, randomly generated to take time, random is actually the seeds of time, but in the case of not connected to the Internet, RTC the initialization of the same circumstances, delivery time should be for the board is the same, the random serial number is the only? If not, how to ensure that the serial number that the only?

CodePudding user response:

Time is accurate to seconds, in time for the seeds, then can guarantee each serial number of the seeds are all the same time?

CodePudding user response:

 # pragma comment (lib, "ole32") 
#include
#include
The union U {
GUID GUID.
Unsigned char b [16].
} u;
int i;
Char s [33];
Void main () {
If (S_OK!=CoCreateGuid (& amp; U.g uid)) return;
for (i=0; i<16. I++) sprintf (s + I * 2, "x % 02," u.b [I]);
Printf (" GUID=% s \ n ", s);//every result is not the same as
}
//GUID=f5a44443aa5fb1479bf6741fa213d33c

CodePudding user response:

reference 1/f, confident boy reply:
time is accurate to seconds, in time for the seeds, then can guarantee each serial number of the seeds are all the same time?

In fact, there are two doubts, one is single chip microcomputer call time function reference is in what time? If RTC the seeds could be the same time, because the RTC need to initialize a time, in reality the factory of the RTC initialization is certainly a code, which is the factory should be the same time, it may be time as the seed of the random number to step in,

CodePudding user response:

refer to the second floor 4 teacher zhao response:
 # pragma comment (lib, "ole32") 
#include
#include
The union U {
GUID GUID.
Unsigned char b [16].
} u;
int i;
Char s [33];
Void main () {
If (S_OK!=CoCreateGuid (& amp; U.g uid)) return;
for (i=0; i<16. I++) sprintf (s + I * 2, "x % 02," u.b [I]);
Printf (" GUID=% s \ n ", s);//every result is not the same as
}
//GUID=f5a44443aa5fb1479bf6741fa213d33c

thank you, not just don't know how to generate a random number, is another question

CodePudding user response:

On the quantum chip!

CodePudding user response:

reference 1/f, confident boy reply:
time is accurate to seconds, in time for the seeds, then can guarantee each serial number of the seeds are all the same time?
view, top write a single-chip microcomputer timer to value, but the effect is the same, the same piece of code must be timed, so join the seeds should be the same

CodePudding user response:

Some single chip microcomputer with noise generator,
  • Related