$ getrandom

v0.3.4

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

Downloads: 844.5M
Recent: 141.4M
Versions: 43
Updated: January 11, 2026

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))
}

Linkshttps://crates.io/crates/getrandomhttps://docs.rs/getrandomhttps://github.com/rust-random/getrandom/pull/667https://github.com/rust-random/getrandom/issues/671https://github.com/rust-random/getrandom/pull/675https://github.com/rust-random/getrandom/pull/678https://github.com/rust-random/getrandom/pull/688https://github.com/rust-random/getrandom/pull/694https://github.com/rust-random/getrandom/pull/699https://github.com/rust-random/getrandom/pull/721https://github.com/rust-random/getrandom/pull/724https://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

677.8M844.5M

$ VERSION HISTORY

v0.3.4January 11, 2026
v0.3.4December 27, 2025
v0.3.4October 14, 2025
v0.3.3May 9, 2025

$ LINKS

$ INSTALL

cargo add getrandom

Or add to Cargo.toml: getrandom = "0.3.4"