commit | ab926dc0ed4c34c814d3d5f6db28ac2fe363bf25 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Sun Nov 06 22:28:56 2022 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Sun Nov 06 22:28:56 2022 +0000 |
tree | aea8128a071e1ea6d7b6ce26379865efb0862da9 | |
parent | 5f1ca0fb13ab78b8d5b74dbcf908094be84f7da2 [diff] | |
parent | 57e7b291aba82e52fe1e8827b2babca2f911f3b6 [diff] |
Snap for 9261351 from 57e7b291aba82e52fe1e8827b2babca2f911f3b6 to mainline-mediaprovider-release Change-Id: I8fba5ca63f0970775d872f9bffac5e1abc93ba1b
A Rust library for retrieving random data from (operating) system source. It is assumed that system always provides high-quality cryptographically secure random data, ideally backed by hardware entropy sources. This crate derives its name from Linux‘s getrandom
function, but is cross platform, roughly supporting the same set of platforms as Rust’s std
lib.
This is a low-level API. Most users should prefer using high-level random-number library like rand
.
Add this to your Cargo.toml
:
[dependencies] getrandom = "0.2"
Then invoke the getrandom
function:
fn get_random_buf() -> Result<[u8; 32], getrandom::Error> { let mut buf = [0u8; 32]; getrandom::getrandom(&mut buf)?; Ok(buf) }
For more information about supported targets, entropy sources, no_std
targets, crate features, WASM support and Custom RNGs see the getrandom
documentation and getrandom::Error
documentation.
This crate requires Rust 1.34.0 or later.
The getrandom
library is distributed under either of
at your option.