• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..15-Mar-2021-

benches/H15-Mar-2021-2521

src/H15-Mar-2021-1,224744

tests/H15-Mar-2021-6245

.cargo-checksum.jsonH A D15-Mar-20212.1 KiB11

CHANGELOG.mdH A D15-Mar-2021652 2315

Cargo.tomlH A D15-Mar-20211.6 KiB5348

LICENSE-APACHEH A D15-Mar-202110.6 KiB202169

LICENSE-MITH A D15-Mar-20211.1 KiB2723

README.mdH A D15-Mar-20212 KiB6843

README.md

1# getrandom
2
3[![Build Status](https://travis-ci.org/rust-random/getrandom.svg?branch=master)](https://travis-ci.org/rust-random/getrandom)
4[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/getrandom?svg=true)](https://ci.appveyor.com/project/rust-random/getrandom)
5[![Crate](https://img.shields.io/crates/v/getrandom.svg)](https://crates.io/crates/getrandom)
6[![Documentation](https://docs.rs/getrandom/badge.svg)](https://docs.rs/getrandom)
7[![Dependency status](https://deps.rs/repo/github/rust-random/getrandom/status.svg)](https://deps.rs/repo/github/rust-random/getrandom)
8
9
10A Rust library for retrieving random data from (operating) system source. It is
11assumed that system always provides high-quality cryptographically secure random
12data, ideally backed by hardware entropy sources. This crate derives its name
13from Linux's `getrandom` function, but is cross platform, roughly supporting
14the same set of platforms as Rust's `std` lib.
15
16This is a low-level API. Most users should prefer using high-level random-number
17library like [`rand`].
18
19[`rand`]: https://crates.io/crates/rand
20
21
22## Usage
23
24Add this to your `Cargo.toml`:
25
26```toml
27[dependencies]
28getrandom = "0.1"
29```
30
31Then invoke the `getrandom` function:
32
33```rust
34fn get_random_buf() -> Result<[u8; 32], getrandom::Error> {
35    let mut buf = [0u8; 32];
36    getrandom::getrandom(&mut buf)?;
37    buf
38}
39```
40
41## Features
42
43This library is `no_std` compatible, but uses `std` on most platforms.
44
45The `log` library is supported as an optional dependency. If enabled, error
46reporting will be improved on some platforms.
47
48For WebAssembly (`wasm32`), WASI and Emscripten targets are supported directly; otherwise
49one of the following features must be enabled:
50
51-   [`wasm-bindgen`](https://crates.io/crates/wasm_bindgen)
52-   [`stdweb`](https://crates.io/crates/stdweb)
53
54## Minimum Supported Rust Version
55
56This crate requires Rust 1.32.0 or later.
57
58
59# License
60
61The `getrandom` library is distributed under either of
62
63 * [Apache License, Version 2.0](LICENSE-APACHE)
64 * [MIT license](LICENSE-MIT)
65
66at your option.
67
68