MCPcopy Index your code
hub / github.com/RustPython/RustPython / rand_bytes

Function rand_bytes

crates/stdlib/src/openssl.rs:515–522  ·  view source on GitHub ↗
(n: i32, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

513
514 #[pyfunction(name = "RAND_bytes")]
515 fn rand_bytes(n: i32, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
516 if n < 0 {
517 return Err(vm.new_value_error("num must be positive"));
518 }
519 let mut buf = vec![0; n as usize];
520 openssl::rand::rand_bytes(&mut buf).map_err(|e| convert_openssl_error(vm, e))?;
521 Ok(buf)
522 }
523
524 // Callback data stored in SSL ex_data for SNI/msg callbacks
525 struct SniCallbackData {

Callers

nothing calls this directly

Calls 2

convert_openssl_errorFunction · 0.85
ErrClass · 0.50

Tested by

no test coverage detected