commit | 57e7b291aba82e52fe1e8827b2babca2f911f3b6 | [log] [tgz] |
---|---|---|
author | Josh Wu <[email protected]> | Thu Jul 28 23:19:01 2022 +0800 |
committer | Henri Chataing <[email protected]> | Tue Nov 01 16:41:42 2022 +0000 |
tree | aea8128a071e1ea6d7b6ce26379865efb0862da9 | |
parent | 02c6f7e3c7f611831a0d029baae07f4f7c357091 [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.