commit | 604df6efbb6fb05fc8b52229639fd5e45ba6bc37 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Wed Dec 14 02:46:17 2022 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Wed Dec 14 02:46:17 2022 +0000 |
tree | 70709274fc5fe7f06eb59587d4b5b012b348dc83 | |
parent | d090ae3e1588c495288c00c5346ad55eed35b691 [diff] | |
parent | 37410dce366e5f0eab0a7fed935cd26c65494e75 [diff] |
Snap for 9401934 from 37410dce366e5f0eab0a7fed935cd26c65494e75 to udc-release Change-Id: Ib54de400145992e3343443812e15e6b394f6696f
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.