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
62
63
64
65
66
67
68
//! Utility functions for generating random values and byte sequences.
use ;
extern "C"
/// The *random()* function returns an unpredictable value between 0 and
/// 0xffffffff (included).
///
/// # Examples
///
/// ```
/// use sodium_sys::crypto::utils::randombytes;
///
/// let r0 = randombytes::random();
/// let r1 = randombytes::random();
/// assert!(r0 != r1);
/// ```
/// The *uniform()* function returns an unpredictable value between 0 and
/// upper_bound (excluded). Unlike *random()* % upper_bound, it does its best
/// to guarantee a uniform distribution of the possible output values.
///
/// The *uniform()* function safely wraps the *randombytes_uniform()* function.
///
/// # Examples
///
/// ```
/// use sodium_sys::crypto::utils::randombytes;
///
/// let r0 = randombytes::uniform(10);
/// assert!(r0 < 10);
/// ```
/// The *random_byte_array()* function fills the given mutable byte array with
/// an unpredictable sequence of bytes.
///
/// The *random_byte_array()* function safely wrap the *randombytes_buf()*
/// function.
///
/// # Examples
///
/// ```
/// use sodium_sys::crypto::utils::randombytes;
///
/// let mut ra0 = [0; 16];
/// randombytes::random_byte_array(&mut ra0);
/// assert!(ra0 != [0; 16]);
/// ```