commit | 6d342a6c6f96d2e2fd93d646d2333899293bb346 | [log] [tgz] |
---|---|---|
author | Linux Build Service Account <lnxbuild@localhost> | Wed Feb 16 21:39:35 2022 -0800 |
committer | Linux Build Service Account <lnxbuild@localhost> | Wed Feb 16 21:39:35 2022 -0800 |
tree | ce60cbf9c98add0e1123950b82f3bc0affe9f212 | |
parent | 06aeaf39c868d11400cc912b659dc04a75cfe460 [diff] | |
parent | f03282a64cef4c06bd48570a518372748fe252c7 [diff] |
Merge f03282a64cef4c06bd48570a518372748fe252c7 on remote branch Change-Id: I250a66cd824966bd10c5a295c45be40a96881ffe
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.