UUIDジェネレーター (バージョン4)
UUIDバージョン4(疑似ランダム)を生成する、128ビットのランダムな識別子であり、一意と見なすことができます。 UUIDは、Globally Unique Identifier(GUID)としても知られています。
生成されたUUID:
UUIDバージョン4についてもっと知る
UUID version 4 is generated using a pseudo-random or random number generator to create a 128-bit identifier. Here are the steps to generate a UUID version 4:
Generate 16 bytes (128 bits) of random data using a secure random number generator. This data can be generated using cryptographic libraries, operating system APIs, or hardware random number generators.
Set the version number. The version number for UUID version 4 is
0100
in binary or4
in hexadecimal. This value is set in the most significant 4 bits of the 7th byte of the UUID.Set the variant. The variant number for UUID version 4 is
10
in binary or8
,9
,A
, orB
in hexadecimal. This value is set in the most significant 2 bits of the 9th byte of the UUID.Combine the generated random data with the version number and variant number to form a 128-bit UUID.
Format the UUID as a string of 32 hexadecimal digits, grouped in five sections separated by hyphens. The format of the string is typically:
xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
, where eachx
represents a hexadecimal digit andy
is a hexadecimal digit that represents the variant.
Here's an example of how a UUID version 4 might be generated:
Generate 16 bytes of random data:
6c 8c 75 1f 0d aa a7 21 98 c1 46 11 10 f2 03 67
.Set the version number:
0100
.Set the variant number:
1000
(or8
,9
,A
, orB
in hexadecimal).Combine the random data, version number, and variant number to form the UUID:
6c8c751f-0daa-4217-98c1-461110f20367
.The resulting UUID is a unique identifier that is very unlikely to be duplicated.
Note that while UUID version 4 is very likely to be unique, it is not guaranteed to be unique in every circumstance. In rare cases, it is possible to generate duplicate UUIDs if two systems generate the same random data at the same time. However, the probability of generating a duplicate UUID is extremely low.