crypto/random.rs
1/// Returns an array filled with cryptographically-random data.
2#[inline]
3pub fn random_bytes<const N: usize>() -> [u8; N] {
4 let mut buf = [0u8; N];
5 getrandom::fill(&mut buf).expect("getrandom failed");
6 buf
7}
8
9/// Fill the given buffer with cryptographically-random data.
10#[inline]
11pub fn random_fill(buf: &mut [u8]) {
12 getrandom::fill(buf).expect("getrandom failed");
13}