| Crates.io | clr_random |
| lib.rs | clr_random |
| version | 0.1.0 |
| created_at | 2025-12-23 01:08:32.09305+00 |
| updated_at | 2025-12-23 01:08:32.09305+00 |
| description | .NET CLR Random implementation in Rust |
| homepage | |
| repository | https://gitlab.com/DrakeTDL/CLRRandom-rs |
| max_upload_size | |
| id | 2000551 |
| size | 11,697 |
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.
no_std compatibleSystem.RandomThis generator is NOT cryptographically secure. Do not use it for security-sensitive applications such as:
[dependencies]
clr_random = "0.1.0"
use clr_random::{CLRRandom, Seed};
use rand_core::{RngCore, SeedableRng};
// Create a new generator from a 32-bit seed.
let mut rng = CLRRandom::from_seed(0.into());
// Generate a random number.
let num1 = rng.next_i32();
// The generated numbers are deterministic.
let mut rng2 = CLRRandom::from_seed(0.into());
assert_eq!(num1, rng2.next_i32());
assert_eq!(num1, 1559595546);