Skip to main content

random_bytes

Function random_bytes 

Source
pub fn random_bytes(len: usize) -> Vec<u8> 
Expand description

Generate len cryptographically secure random bytes.

Uses the operating system’s CSPRNG via the getrandom crate. Returns an empty Vec if len is 0.

§Panics

Panics if the OS random number generator fails, which should only happen in extremely unusual circumstances (e.g., very early boot on a system with no entropy sources).