pub fn random_bytes(len: Option<i64>) -> Result<Vec<u8>, Error>
Expand description

Generate a vector of random bytes.

If len is Some and non-negative, generate a vector of len random bytes. If len is None, generate 16 random bytes.


let bytes = spinoso_securerandom::random_bytes(Some(1024))?;
assert_eq!(bytes.len(), 1024);


If the given length is negative, return an ArgumentError.

If the underlying source of randomness returns an error, return a RandomBytesError.

If an allocation error occurs, an error is returned.