Packages / rupm

rs-random-prng 0.1.0

Seedable PRNGs (SplitMix64, xorshift64, PCG32) with shuffle, choose and unbiased ranges; non-cryptographic

Install

cargo add rs-random-prng --registry rupm

In Ruststudio: Packages, search for rs-random-prng, Install.

Owner: Rust Studio. Licence: MIT OR Apache-2.0. Total downloads: 0. Published 2026-11-23.

Versions

README

# rs-random-prng

Seedable PRNGs (SplitMix64, xorshift64, PCG32) with shuffle, choose and unbiased ranges; non-cryptographic

Add it with `rupm add rs-random-prng` (or `cargo add rs-random-prng --registry rupm`).

NOT cryptographically secure. Use it for games, simulations, tests and shuffling, never for passwords, keys, tokens or anything security-critical. The seed from from_entropy() mixes the standard library's randomly keyed hasher with the clock; it is not a cryptographic entropy source.

```rust
use rs_random_prng::{Pcg32, Rng};
let mut a = Pcg32::new(42, 54);
assert_eq!(a.next_u32(), 0xa15c_02b7); // reference value from the PCG paper demo
let mut rng = Pcg32::from_entropy();
let mut v = vec![1, 2, 3, 4, 5];
rng.shuffle(&mut v);
let pick = rng.choose(&v);
assert!(pick.is_some());
```