uuid / com.benasher44.uuid / uuid4

uuid4

expect fun uuid4(): Uuid

Platform and version requirements: JVM

Construct new version 4 UUID.

Version 4 UUIDs are randomly generated from the best available random source. The selection of that source is depends on the platform. Some systems may be bad at generating sufficient entropy, e.g. virtual machines, and this might lead to collisions faster than desired. Version 5 may be used if this is the case and no other measures are possible to increase the entropy of the random source of the platform.

val uuid = uuid4()

assertEquals(4, uuid.version)
assertEquals(2, uuid.variant)

Return
New version 4 UUID of random data.