diff options
| author | Jordi Boggiano <j.boggiano@seld.be> | 2013-08-06 22:13:26 +0200 |
|---|---|---|
| committer | Corey Richardson <corey@octayn.net> | 2013-08-07 22:41:13 -0400 |
| commit | 3db9dc1dfd8038862b06b712ece75fd7d17339af (patch) | |
| tree | 906fdc6d88256807957a6347d40a4b81b8c5c4f2 /src | |
| parent | a9b7bec2e7f005431c7424a59095ccda33484bb1 (diff) | |
| download | rust-3db9dc1dfd8038862b06b712ece75fd7d17339af.tar.gz rust-3db9dc1dfd8038862b06b712ece75fd7d17339af.zip | |
Document rand module with more emphasis on cryptographic security
Diffstat (limited to 'src')
| -rw-r--r-- | src/libstd/rand.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs index 4ef524d7715..4408e5e1f27 100644 --- a/src/libstd/rand.rs +++ b/src/libstd/rand.rs @@ -610,6 +610,11 @@ impl<R: Rng> RngUtil for R { } /// Create a random number generator with a default algorithm and seed. +/// +/// It returns the cryptographically-safest `Rng` algorithm currently +/// available in Rust. If you require a specifically seeded `Rng` for +/// consistency over time you should pick one algorithm and create the +/// `Rng` yourself. pub fn rng() -> IsaacRng { IsaacRng::new() } @@ -619,6 +624,8 @@ static RAND_SIZE: u32 = 1 << RAND_SIZE_LEN; /// A random number generator that uses the [ISAAC /// algorithm](http://en.wikipedia.org/wiki/ISAAC_%28cipher%29). +/// +/// The ISAAC algorithm is suitable for cryptographic purposes. pub struct IsaacRng { priv cnt: u32, priv rsl: [u32, .. RAND_SIZE], @@ -794,8 +801,11 @@ impl Rng for IsaacRng { } /// An [Xorshift random number -/// generator](http://en.wikipedia.org/wiki/Xorshift). Not suitable for -/// cryptographic purposes. +/// generator](http://en.wikipedia.org/wiki/Xorshift). +/// +/// The Xorshift algorithm is not suitable for cryptographic purposes +/// but is very fast. If you do not know for sure that it fits your +/// requirements, use a more secure one such as `IsaacRng`. pub struct XorShiftRng { priv x: u32, priv y: u32, |
