$ getrandom
v0.3.4A small cross-platform library for retrieving random data from system source
Latest Update Summary
Crate
Name: getrandom New version: 0.3.4 Release date: 2025-10-14T17:52:59Z
Crate readme
Short description getrandom is a Rust library for retrieving random data from system sources.
Long description
getrandom provides a low-level API to access random data from various system sources across platforms like Linux, Windows, and macOS. It supports multiple backends to customize the source of randomness and offers seamless operation for users, requiring Rust 1.63 or later. The crate prioritizes performance and security, ensuring that it delivers cryptographically secure random data, ideally backed by hardware entropy sources. Users are advised to use higher-level libraries like rand for most applications.
Features
• Cargo feature flags: wasm_js for WebAssembly support
• Cross-platform support for various OS including Linux, Windows, macOS
• Compatibility with no_std environments
• Minimum Supported Rust Version: 1.63
• Option to enable custom and opt-in backends for flexibility
Code Examples Add to Cargo.toml
[dependencies]
getrandom = "0.3"
Basic usage
fn get_random_u128() -> Result<u128, getrandom::Error> {
let mut buf = [0u8; 16];
getrandom::fill(&mut buf)?;
Ok(u128::from_ne_bytes(buf))
}
Links • https://crates.io/crates/getrandom • https://docs.rs/getrandom • https://github.com/rust-random/getrandom/pull/667 • https://github.com/rust-random/getrandom/issues/671 • https://github.com/rust-random/getrandom/pull/675 • https://github.com/rust-random/getrandom/pull/678 • https://github.com/rust-random/getrandom/pull/688 • https://github.com/rust-random/getrandom/pull/694 • https://github.com/rust-random/getrandom/pull/699 • https://github.com/rust-random/getrandom/pull/721 • https://github.com/rust-random/getrandom/pull/724 • https://github.com/rust-random/getrandom/pull/730 https://docs.rs/getrandom https://api.github.com/repos/rust-random/getrandom/releases/254457604
Release info
Release version: 0.3.4
Release description
In version 0.3.4, the wasm_js backend is now used by default when the wasm_js feature is enabled, simplifying the process for users targeting JavaScript environments. This change eliminates the need to specify --cfg getrandom_backend="wasm_js" in RUSTFLAGS. However, it remains applicable to non-JS users, as they can still override the backend configuration. Additional updates include the introduction of unsupported and windows_legacy opt-in backends, and various improvements such as more precise Memory Sanitizer unpoisoning and relaxation of the Minimum Supported Rust Version (MSRV) for ARM targets. The version also removes an unstable crate feature, providing a more streamlined experience.
Code Examples
Enable wasm_js feature
// Example to enable `wasm_js` feature in Cargo.toml
[features]
wasm_js = []
Patch update: 0.3.4 → 0.3.4
$ DOWNLOADS TREND
$ VERSION HISTORY
$ LINKS
$ INSTALL
cargo add getrandomOr add to Cargo.toml: getrandom = "0.3.4"