CLRRandom
A Rust implementation of the .NET CLR Random number generator that is
compatible with no_std environments.
This library provides a deterministic pseudo-random number generator that
produces the same sequence of numbers as the .NET Framework's System.Random
class when initialized with the same seed. This is useful for cross-platform
applications that need to maintain compatibility with .NET implementations.
Note on Compatibility: Only the methods [next_i32] (equivalent to .NET's Next()),
fill_bytes (equivalent to .NET's NextBytes()), and next_f64 (equivalent to .NET's NextDouble())
are guaranteed to exhibit exact behavior matching the .NET implementation.
Features
no_stdcompatible- Deterministic output matching .NET CLR
System.Random - Minimal dependencies
- Simple and efficient API
Security Warning
This generator is NOT cryptographically secure. Do not use it for security-sensitive applications such as:
- Generating cryptographic keys
- Creating authentication tokens
- Security-critical random values
Installation
[]
= "0.1.0"
Quick Start
use ;
use ;
// Create a new generator from a 32-bit seed.
let mut rng = from_seed;
// Generate a random number.
let num1 = rng.next_i32;
// The generated numbers are deterministic.
let mut rng2 = from_seed;
assert_eq!;
assert_eq!;