#rng

no-std msws

Middle Square Weyl Sequence pseudorandom number generator

2 unstable releases

0.2.0 Sep 8, 2019
0.1.0 Jun 25, 2019

#2464 in Algorithms

MIT license

7KB
122 lines

Middle Square Weyl Sequence

Middle Square Weyl Sequence pseudorandom number generator (no_std).

Example

use msws::Rand;

// This will always return the same seed.
msws::seed(0); // => 0xb5ad4eceda1ce2a9

let seed = 0xb5ad4eceda1ce2a9;
let mut r = Rand::new(seed).expect("invalid seed");
r.rand(); // => 0xb5ad4ece

Crypto

Pseudorandom number generators should not be used for crypto.

License

MIT


lib.rs:

Middle Square Weyl Sequence pseudorandom number generator (no_std).

Example

use msws::Rand;

// This will always return the same seed.
msws::seed(0); // => 0xb5ad4eceda1ce2a9

let seed = 0xb5ad4eceda1ce2a9;
let mut r = Rand::new(seed).expect("invalid seed");
r.rand(); // => 0xb5ad4ece

Crypto

Pseudorandom number generators should not be used for crypto.

No runtime deps