Skip to content

Commit 9397fe0

Browse files
committed
Add weak_rng to get a random algo that puts more emphasis on speed than security
1 parent c873c21 commit 9397fe0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libstd/rand.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,16 @@ pub fn rng() -> IsaacRng {
619619
IsaacRng::new()
620620
}
621621

622+
/// Create a weak random number generator with a default algorithm and seed.
623+
///
624+
/// It returns the fatest `Rng` algorithm currently available in Rust without
625+
/// consideration for cryptography or security. If you require a specifically
626+
/// seeded `Rng` for consistency over time you should pick one algorithm and
627+
/// create the `Rng` yourself.
628+
pub fn weak_rng() -> XorShiftRng {
629+
XorShiftRng::new()
630+
}
631+
622632
static RAND_SIZE_LEN: u32 = 8;
623633
static RAND_SIZE: u32 = 1 << RAND_SIZE_LEN;
624634

0 commit comments

Comments
 (0)