| commit | 6faa01ec63389679829118250276c26652708fb9 | [log] [tgz] |
|---|---|---|
| author | Josh Wu <joshwu@google.com> | Thu Jul 28 23:19:01 2022 +0800 |
| committer | Henri Chataing <henrichataing@google.com> | Wed Oct 19 18:03:46 2022 +0000 |
| tree | aea8128a071e1ea6d7b6ce26379865efb0862da9 | |
| parent | 67ee42f84fb56bd3a9278b1062bc12f6639988ae [diff] |
Make crate vendor available Test: m Bug: 235777894 Bug: 245578454 Ignore-AOSP-First: cherry-pick from AOSP Merged-In: Id9d56df3dbf101899054a42e0eba6e024eb9de7e Change-Id: Id9d56df3dbf101899054a42e0eba6e024eb9de7e (cherry picked from commit 8d4e6d556646b9abf047ce82b7745e091749a8c6)
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.