Skip to main content

random_bytes

Function random_bytes 

Source
pub fn random_bytes(length: usize) -> Result<Uint8Array, String>
Expand description

Generate cryptographically secure random bytes for WASM

This function provides secure random generation in WASM environments:

  • Uses the browser’s crypto.getRandomValues() API
  • Validates input size to prevent DoS attacks
  • Returns Uint8Array for direct JavaScript consumption