about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJordi Boggiano <j.boggiano@seld.be>2013-08-06 22:14:32 +0200
committerCorey Richardson <corey@octayn.net>2013-08-07 22:41:14 -0400
commit403c52d2ae1a59dea1a3b04ad794a66bd687d067 (patch)
treed02bae63a0dc3181a98e3e923754408f9c0500d8
parent3db9dc1dfd8038862b06b712ece75fd7d17339af (diff)
downloadrust-403c52d2ae1a59dea1a3b04ad794a66bd687d067.tar.gz
rust-403c52d2ae1a59dea1a3b04ad794a66bd687d067.zip
Add weak_rng to get a random algo that puts more emphasis on speed than security
-rw-r--r--src/libstd/rand.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs
index 4408e5e1f27..5f8fa9fddbc 100644
--- a/src/libstd/rand.rs
+++ b/src/libstd/rand.rs
@@ -619,6 +619,16 @@ pub fn rng() -> IsaacRng {
     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: u32 = 1 << RAND_SIZE_LEN;