commit | 50b53c6be2d0e5fc9188214c58df3cf2cf9b62a3 | [log] [tgz] |
---|---|---|
author | Josh Wu <[email protected]> | Fri Jul 29 06:00:45 2022 +0000 |
committer | Automerger Merge Worker <[email protected]> | Fri Jul 29 06:00:45 2022 +0000 |
tree | a55fccf56f120437c56d5496d7b61719e2a9edf3 | |
parent | f789f2ce2752a00e1caf5ed5e14cddb273e989a1 [diff] | |
parent | 8d4e6d556646b9abf047ce82b7745e091749a8c6 [diff] |
Make crate vendor available am: 8d4e6d5566 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/getrandom/+/2168682 Change-Id: I7afc18124f4f1cf391c406b87d01a29f434214bc Signed-off-by: Automerger Merge Worker <[email protected]>
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.