Compare commits

...

6 Commits

Author SHA1 Message Date
d9454fcdb2 Merge pull request '1.3.1 Release' (#5) from develop into main
All checks were successful
/ publish (push) Successful in 3m6s
Reviewed-on: Infendro/prng-kt#5
2026-03-12 10:34:32 +00:00
06d86a6679 Bump version to 1.3.1
All checks were successful
/ test (pull_request) Successful in 25s
2026-03-12 11:33:28 +01:00
a28cb7d2f9 Upgrade dependencies 2026-03-12 11:32:31 +01:00
8fab26a476 Fix algorithm name in README 2026-02-19 12:57:36 +01:00
3465a60cb1 Merge pull request '1.3.0 release' (#4) from develop into main
All checks were successful
/ publish (push) Successful in 1m50s
Reviewed-on: Infendro/prng-kt#4
2026-02-19 11:56:22 +00:00
2aed836e67 Upgrade dependencies
All checks were successful
/ test (pull_request) Successful in 32s
2026-02-19 12:46:41 +01:00
6 changed files with 20 additions and 12 deletions

View File

@@ -4,6 +4,8 @@
Supported [PRNG](https://en.wikipedia.org/wiki/Pseudorandom_number_generator) algorithms:
- LCG
- xoshiro256++
- xoshiro256**
Supported [CSPRNG](https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator) algorithms:
- HMAC-DRBG
@@ -18,7 +20,7 @@ repositories {
}
dependencies {
implementation("com.infendro:prng:1.3.0")
implementation("com.infendro:prng:1.3.1")
}
```
@@ -27,7 +29,7 @@ dependencies {
```kotlin
fun main() {
// create PRNG instance
val rng = CSPRNG.HMAC(`SHA-256`)
val rng = CSPRNG.HMAC(`SHA-256`())
// seed PRNG to receive deterministic numbers
rng.seed(/* seed */)

View File

@@ -5,7 +5,7 @@ import com.infendro.plugin.token
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
group = "com.infendro"
version = "1.3.0"
version = "1.3.1"
plugins {
alias(libs.plugins.infendro)
@@ -31,9 +31,9 @@ kotlin {
sourceSets {
commonMain.dependencies {
implementation(libs.bytes)
implementation(libs.hash)
implementation(libs.mac)
implementation(libs.bytes)
}
}
}

View File

@@ -1,15 +1,15 @@
[versions]
infendro = "1.1.0"
kotlin = "2.3.0"
mac = "1.3.0"
hash = "1.5.1"
bytes = "1.3.3"
bytes = "1.4.2"
hash = "1.7.0"
mac = "1.5.0"
[plugins]
infendro = { id = "com.infendro.plugin", version.ref = "infendro" }
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
[libraries]
mac = { module = "com.infendro:mac", version.ref = "mac" }
hash = { module = "com.infendro:hash", version.ref = "hash" }
bytes = { module = "com.infendro:bytes", version.ref = "bytes" }
hash = { module = "com.infendro:hash", version.ref = "hash" }
mac = { module = "com.infendro:mac", version.ref = "mac" }

View File

@@ -6,6 +6,8 @@ import com.infendro.random.PRNG
import kotlin.properties.Delegates.notNull
class LCG : PRNG() {
private val function = `SHA-256`()
private val a: Long = 25214903917L
private val c: Long = 11L
private val mask: Long = (1L shl 48) - 1
@@ -13,7 +15,7 @@ class LCG : PRNG() {
private var x: Long by notNull()
override fun seed(seed: ByteArray) {
x = `SHA-256`.hash(seed).toLong() and mask
x = function.hash(seed).toLong() and mask
}
override fun generate(): Int {

View File

@@ -6,10 +6,12 @@ import com.infendro.random.PRNG
import kotlin.properties.Delegates.notNull
class Xoshiro256pp : PRNG() {
private val function = `SHA-256`()
private var s: LongArray by notNull()
override fun seed(seed: ByteArray) {
s = `SHA-256`.hash(seed).toLongArray()
s = function.hash(seed).toLongArray()
}
override fun generate(): Int {

View File

@@ -6,10 +6,12 @@ import com.infendro.random.PRNG
import kotlin.properties.Delegates.notNull
class Xoshiro256ss : PRNG() {
private val function = `SHA-256`()
private var s: LongArray by notNull()
override fun seed(seed: ByteArray) {
s = `SHA-256`.hash(seed).toLongArray()
s = function.hash(seed).toLongArray()
}
override fun generate(): Int {