implement optimizations
This commit is contained in:
31
README.md
31
README.md
@@ -6,16 +6,7 @@ Supported [PRNG](https://en.wikipedia.org/wiki/Pseudorandom_number_generator) al
|
||||
- LCG
|
||||
|
||||
Supported [CSPRNG](https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator) algorithms:
|
||||
- HMAC DRBG
|
||||
|
||||
## Targets
|
||||
|
||||
| Target | Status |
|
||||
|------------------|---------------|
|
||||
| JVM | Supported |
|
||||
| JavaScript | Supported |
|
||||
| Native (Linux) | Supported |
|
||||
| Native (Windows) | Not Supported |
|
||||
- HMAC-DRBG
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -27,34 +18,30 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("com.infendro:prng:1.2.0")
|
||||
implementation("com.infendro:prng:1.3.0")
|
||||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```kotlin
|
||||
import com.infendro.hash.sha2.`SHA-256`
|
||||
import com.infendro.random.csprng.CSPRNG
|
||||
|
||||
fun main() {
|
||||
// create a PRNG instance
|
||||
// create PRNG instance
|
||||
val rng = CSPRNG.HMAC(`SHA-256`)
|
||||
|
||||
// seed the PRNG to receive predictable results
|
||||
rng.seed(/* some seed */)
|
||||
// seed PRNG to receive deterministic numbers
|
||||
rng.seed(/* 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 */)
|
||||
// reseed PRNG to add additional entropy
|
||||
rng.reseed(/* 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)
|
||||
// a, b, and c will be deterministic
|
||||
// d, e, and f will be random (assuming entropy is random)
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user