| 1 | # rand_chacha |
| 2 | |
| 3 | [](https://github.com/rust-random/rand/actions) |
| 4 | [](https://crates.io/crates/rand_chacha) |
| 5 | [](https://rust-random.github.io/book/) |
| 6 | [](https://rust-random.github.io/rand/rand_chacha) |
| 7 | [](https://docs.rs/rand_chacha) |
| 8 | |
| 9 | A cryptographically secure random number generator that uses the ChaCha |
| 10 | algorithm. |
| 11 | |
| 12 | ChaCha is a stream cipher designed by Daniel J. Bernstein[^1], that we use |
| 13 | as an RNG. It is an improved variant of the Salsa20 cipher family, which was |
| 14 | selected as one of the "stream ciphers suitable for widespread adoption" by |
| 15 | eSTREAM[^2]. |
| 16 | |
| 17 | The RNGs provided by this crate are implemented via the fast stream ciphers of |
| 18 | the [`c2-chacha`](https://crates.io/crates/c2-chacha) crate. |
| 19 | |
| 20 | Links: |
| 21 | |
| 22 | - [API documentation (master)](https://rust-random.github.io/rand/rand_chacha) |
| 23 | - [API documentation (docs.rs)](https://docs.rs/rand_chacha) |
| 24 | - [Changelog](https://github.com/rust-random/rand/blob/master/rand_chacha/CHANGELOG.md) |
| 25 | |
| 26 | [rand]: https://crates.io/crates/rand |
| 27 | [^1]: D. J. Bernstein, [*ChaCha, a variant of Salsa20*]( |
| 28 | https://cr.yp.to/chacha.html) |
| 29 | |
| 30 | [^2]: [eSTREAM: the ECRYPT Stream Cipher Project]( |
| 31 | http://www.ecrypt.eu.org/stream/) |
| 32 | |
| 33 | |
| 34 | ## Crate Features |
| 35 | |
| 36 | `rand_chacha` is `no_std` compatible when disabling default features; the `std` |
| 37 | feature can be explicitly required to re-enable `std` support. Using `std` |
| 38 | allows detection of CPU features and thus better optimisation. Using `std` |
| 39 | also enables `os_rng` functionality, such as `ChaCha20Rng::from_os_rng()`. |
| 40 | |
| 41 | |
| 42 | # License |
| 43 | |
| 44 | `rand_chacha` is distributed under the terms of both the MIT license and the |
| 45 | Apache License (Version 2.0). |
| 46 | |
| 47 | See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and |
| 48 | [COPYRIGHT](COPYRIGHT) for details. |