commit | 5221cd66a135107bcd8c99dc135f891488fde560 | [log] [tgz] |
---|---|---|
author | Andrew Walbran <[email protected]> | Fri Jun 18 15:00:02 2021 +0000 |
committer | Automerger Merge Worker <[email protected]> | Fri Jun 18 15:00:02 2021 +0000 |
tree | 98c50f84c0c05abbe12065197057b1dff5622f61 | |
parent | 1e9041d543cbe4d45e500ae2d8152faf8b52c649 [diff] | |
parent | f338cf370e3d40ffe010bcbf8a508f7dfd3fd8cc [diff] |
Allow use in virt APEX. am: f338cf370e Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/getrandom/+/1736222 Change-Id: I361e5ccbda1917a19b310a94a3d2c7b426b5ac6d
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.