mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Add weak_rng to get a random algo that puts more emphasis on speed than security
This commit is contained in:
parent
c873c21638
commit
9397fe05e6
@ -619,6 +619,16 @@ pub fn rng() -> IsaacRng {
|
|||||||
IsaacRng::new()
|
IsaacRng::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a weak random number generator with a default algorithm and seed.
|
||||||
|
///
|
||||||
|
/// It returns the fatest `Rng` algorithm currently available in Rust without
|
||||||
|
/// consideration for cryptography or security. If you require a specifically
|
||||||
|
/// seeded `Rng` for consistency over time you should pick one algorithm and
|
||||||
|
/// create the `Rng` yourself.
|
||||||
|
pub fn weak_rng() -> XorShiftRng {
|
||||||
|
XorShiftRng::new()
|
||||||
|
}
|
||||||
|
|
||||||
static RAND_SIZE_LEN: u32 = 8;
|
static RAND_SIZE_LEN: u32 = 8;
|
||||||
static RAND_SIZE: u32 = 1 << RAND_SIZE_LEN;
|
static RAND_SIZE: u32 = 1 << RAND_SIZE_LEN;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user