commit | 2da1b7fa0f7da33fd3ee80016a47646328a66646 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Thu Oct 20 23:15:05 2022 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Thu Oct 20 23:15:05 2022 +0000 |
tree | aea8128a071e1ea6d7b6ce26379865efb0862da9 | |
parent | 67ee42f84fb56bd3a9278b1062bc12f6639988ae [diff] | |
parent | 6faa01ec63389679829118250276c26652708fb9 [diff] |
Snap for 9200392 from 6faa01ec63389679829118250276c26652708fb9 to tm-d4-release Change-Id: I2c7d126a33427ffbeb26e573700e573114938fa5
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.