]> git.lizzy.rs Git - rust.git/commitdiff
Add weak_rng to get a random algo that puts more emphasis on speed than security
authorJordi Boggiano <j.boggiano@seld.be>
Tue, 6 Aug 2013 20:14:32 +0000 (22:14 +0200)
committerCorey Richardson <corey@octayn.net>
Thu, 8 Aug 2013 02:41:14 +0000 (22:41 -0400)
src/libstd/rand.rs

index 4408e5e1f275830490578a487a1fac97d27ed2b4..5f8fa9fddbcf7c2808f06ea9247590d49d4fa297 100644 (file)
@@ -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;