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
use rand::{
    rngs::{SmallRng, StdRng},
    FromEntropy, Rng,
};

pub fn default(size: usize) -> Vec<u8> {
    let mut rng = StdRng::from_entropy();
    let mut result: Vec<u8> = vec![0; size];

    rng.fill(&mut result[..]);

    result
}

#[cfg(test)]
mod test_default {
    use super::*;

    #[test]
    fn generates_random_vectors() {
        let bytes = default(5);

        assert_eq!(bytes.len(), 5);
    }
}

pub fn non_secure(size: usize) -> Vec<u8> {
    let mut rng = SmallRng::from_entropy();
    let mut result = vec![0u8; size];

    rng.fill(&mut result[..]);

    result
}

#[cfg(test)]
mod test_non_secure {
    use super::non_secure;

    #[test]
    fn generates_random_vectors() {
        let bytes = non_secure(5);

        assert_eq!(bytes.len(), 5);
    }
}