Last active
May 2, 2022 09:25
-
-
Save xpepermint/f9a0ab323c48de6440eb6b79ffd8456d to your computer and use it in GitHub Desktop.
Revisions
-
xpepermint revised this gist
May 2, 2022 . 3 changed files with 9 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ fn main() { println!("{:?}", get_random_buf()); } fn get_random_buf() -> Result<[u8; 32], getrandom::Error> { let mut buf = [0u8; 32]; getrandom::getrandom(&mut buf)?; Ok(buf) } File renamed without changes. -
xpepermint revised this gist
May 2, 2022 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ use std::fs::File; use std::io::Read; fn main() { let mut f = File::open("/dev/urandom").unwrap(); // from Linux let mut buf = [0u8; 16]; f.read_exact(&mut buf).unwrap(); println!("{:?}", buf); } -
xpepermint created this gist
May 2, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ fn main() { unsafe { srand(); println!("{}", rand()); } } extern "C" { fn srand() -> u32; fn rand() -> u32; }