1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use Range;
pub use Fortuna;
/// Cryptographically secure pseudorandom number generator.
///
/// A pseudorandom number generator generates random-looking numbers. The reason
/// why they are referred to as _pseudo_ random is because they're not truly
/// random: they're deterministically computed from an initial value called the
/// _seed_. On the other hand, true randomness is referred to as
/// [entropy](Entropy), and typically the seed is generated using a source of
/// entropy.
///
/// The random numbers are yielded by [`into_iter`](IntoIterator::into_iter).
/// A source of entropy.
///
/// Typically, this is a hardware component which generates "true randomness"
/// based on the environment, such as the environmental noise, typing and mouse
/// movement patterns, static noise coming from other hardware components, and
/// other similar unpredictable sources.
///
/// In practical implementations, the source of entropy is usually implemented
/// by the operating system. For example, Linux's [`getrandom`](https://web.archive.org/web/20231003160929/https://man7.org/linux/man-pages/man2/getrandom.2.html).
/// Draw a uniformly random number from a range.
///
/// Being uniformly random means that every number in the range has equal chance
/// of being drawn, except negligible difference.
/// Randomly shuffle the elements of a slice.
///
/// This works by walking the slice and swapping the current element with a
/// random element picked from the remainder of the slice to the right. This is
/// equivalent to randomly removing elements from the slice and pushing them
/// into an empty container, but more efficient since it operates in-place.