From 55658f2b24eaedb7eb049b04430282de8c9f882f Mon Sep 17 00:00:00 2001 From: Infendro Date: Sat, 4 Oct 2025 12:40:38 +0200 Subject: [PATCH] add README --- README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..46c4920 --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# Kotlin OTP + +This library provides various [Pseudorandom Number Generator](https://en.wikipedia.org/wiki/Pseudorandom_number_generator) +implementations in Kotlin Multiplatform. + +## Features + +* Generate random numbers using Kotlin's Random interface. +* Seed the PRNGs to receive predictable results. +* Reseed the PRNGs to add entropy to the following results. +* [HMAC DRBG](https://en.wikipedia.org/wiki/NIST_SP_800-90A#Hash_DRBG_and_HMAC_DRBG) +* Multiplatform support + * JVM + * JavaScript + * Native (Linux) + +## Installation + +Add the following to your `build.gradle.kts`. + +```kotlin +repositories { + maven("https://git.infendro.com/api/packages/Infendro/maven") +} + +dependencies { + implementation("com.infendro:random:1.0.0") +} +``` + +## Usage + +```kotlin +import com.infendro.hash.SHA256 +import com.infendro.random.PRNG + +fun main() { + // create a PRNG instance + val rng = PRNG.HMAC(SHA256) + + // seed the PRNG to receive predictable results + rng.seed(/* some seed */) + val a = rng.nextInt() + val b = rng.nextInt() + val c = rng.nextInt() + + // reseed the PRNG to add entropy to the following results + rng.reseed(/* some random entropy */) + val d = rng.nextInt() + val e = rng.nextInt() + val f = rng.nextInt() + + // each run: + // a, b, and c will be predictable + // d, e, and f will be random (assuming the entropy is also random) +} +```