Skip to main content

random_bytes

Function random_bytes 

Source
pub fn random_bytes(length: u32) -> Result<Vec<u8>, RandomBytesError>
Expand description

Generate cryptographically secure random bytes.

length is the number of bytes to return; the host caps it at 256 and defaults to 32 for non-positive values. Returns the raw bytes (the host’s hex encoding is decoded for you).

Returns an error if the host returned no data or the hex string was malformed - callers MUST treat this as a hard failure for security.