2026-04-16 16:07:58 +00:00
2026-01-30 13:43:33 +01:00
2026-03-12 11:32:31 +01:00
2025-07-24 20:49:21 +02:00
2026-03-12 11:33:28 +01:00
2025-08-16 21:27:07 +02:00
2025-08-16 21:27:07 +02:00
2025-07-24 20:49:21 +02:00
2026-04-16 16:07:58 +00:00
2025-12-13 01:19:11 +01:00

prng.kt

prng.kt is a Kotlin Multiplatform library that provides common Pseudorandom Number Generators.

Supported PRNG algorithms:

  • LCG
  • xoshiro256++
  • xoshiro256**

Supported CSPRNG algorithms:

  • HMAC-DRBG

Installation

Add the following to your build.gradle.kts.

repositories {
    maven("https://git.infendro.com/api/packages/Infendro/maven")
}

dependencies {
    implementation("com.infendro:prng:1.3.1")
}

Usage

fun main() {
    // create PRNG instance
    val rng = CSPRNG.HMAC(`SHA-256`())

    // seed PRNG to receive deterministic numbers
    rng.seed(/* seed */)
    val a = rng.nextInt()
    val b = rng.nextInt()
    val c = rng.nextInt()

    // reseed PRNG to add additional entropy
    rng.reseed(/* entropy */)
    val d = rng.nextInt()
    val e = rng.nextInt()
    val f = rng.nextInt()

    // a, b, and c will be deterministic
    // d, e, and f will be random (assuming entropy is random)
}
Description
No description provided
Readme 170 KiB
Languages
Kotlin 100%