commit | 4954047bd030577afab6f14fbf41b106191acb7e | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Sat Nov 06 01:36:20 2021 +0000 |
committer | Automerger Merge Worker <[email protected]> | Sat Nov 06 01:36:20 2021 +0000 |
tree | 98c50f84c0c05abbe12065197057b1dff5622f61 | |
parent | 15539470b9587137c93ab10ef05a4974b727e69c [diff] | |
parent | 0093f477cbc3aec7d20dd09f466420a88646510d [diff] |
Snap for 7889170 from 6f727a1ec85bded7552f725ecd54a5108a7953ba to sc-v2-release am: 0093f477cb Original change: https://googleplex-android-review.googlesource.com/c/platform/external/rust/crates/getrandom/+/16203650 Change-Id: I3febbfe00e60ee35bd778a8e7ff2f6eea0e5ceb4
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.