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
69
70
//! A simple DRG (Deterministic Random Generator) based on Chacha Stream cipher
//!
/// The ROUNDS parameters of the DRG is the same as ChaCha ROUNDS,
/// and only the value 8, 12 and 20 are valid.
///
/// Note that lowest ROUNDS will produce a faster random generator, but will reduce
/// the margin of security of the cipher
///
/// ```
/// use cryptoxide::drg::chacha::Drg;
/// // Typically should be coming from an entropy generator (see getrandom package),
/// // or some other high quality random value
/// let seed = [1u8; 32];
/// let mut drg = Drg::<8>::new(&seed);
///
/// // produce 25 bytes of random value
/// let random = drg.bytes::<25>();
/// ```
use crateChaCha;
/// A simple DRG (Deterministic Random Generator) based on ChaCha Stream cipher
///
/// The ROUNDS parameters of the DRG is the same as ChaCha ROUNDS,
/// and only the value 8, 12 and 20 are valid.
///
/// Note that lowest ROUNDS will produce a faster random generator, but will reduce
/// the margin of security of the cipher
///
/// Once created the following methods can be used to generate randomness:
///
/// * u32
/// * u64
/// * `bytes<N>`
/// * `fill_bytes<N>`
/// * fill_slice
;