about summary refs log tree commit diff
path: root/library/std/src/sys/random/wasip1.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/sys/random/wasip1.rs')
-rw-r--r--library/std/src/sys/random/wasip1.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/library/std/src/sys/random/wasip1.rs b/library/std/src/sys/random/wasip1.rs
new file mode 100644
index 00000000000..d41da3751fc
--- /dev/null
+++ b/library/std/src/sys/random/wasip1.rs
@@ -0,0 +1,5 @@
+pub fn fill_bytes(bytes: &mut [u8]) {
+    unsafe {
+        wasi::random_get(bytes.as_mut_ptr(), bytes.len()).expect("failed to generate random data")
+    }
+}