Registry / crypto / getrandom

getrandom

JSON →
library0.4.2rscratesunverified

A small cross-platform library for retrieving random data from system source.

# Cargo.toml [dependencies] getrandom = "0.4.2"
INSTALL
IMPORT
SIG · GETRANDOM
G
getrandom
cryptorustv0.4.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getrandom
use getrandom::getrandom;

Fill a buffer with cryptographically secure random bytes.

use getrandom::getrandom; fn main() { let mut buf = [0u8; 16]; getrandom(&mut buf).unwrap(); println!("{:?}", buf); }
Debug
Known issues
gotchaMay block on some platforms (e.g., /dev/random on Linux)
fix
Use getrandom with the "js" feature for WASM or consider using rand::thread_rng for non-cryptographic use
affects: >=0.2.0
Upgrade
Version history
0.4.2latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
getrandom — cargo add getrandom · libregistry