Simple Kotlin Multiplatform library to generate UUIDs.
Library has only one critical dependency - secure-random, adding new platforms is mostly limited by which platforms does this library support.
Currently it is compiled for:
- jvm
- macosArm64
- macosX64
- iosArm64
- iosSimulatorArm64
- iosX64
- js (browser/nodejs)
- wasm (browser/nodejs)
- mingwX64
- linuxX64
Library is published to Maven Central under name io.github.vooft:kt-uuid-core.
Add the dependency to your project:
kotlin {
...
sourceSets {
commonMain.dependencies {
implementation("io.github.vooft:kt-uuid-core:<version>")
}
}
}
API is trying to mirror the java.util.UUID
class as much as possible.
import io.github.vooft.kuuid.UUID
val uuid1 = UUID.randomUUID()
val uuid2 = UUID.fromString("123e4567-e89b-12d3-a456-426614174000")
println(uuid1.toString())
println(uuid2.toString()) // prints "123e4567-e89b-12d3-a456-426614174000"