Expand description
§Vitamin C Random
A carefully designed random number generator that is safe to use for cryptographic purposes.
This crate is part of the Vitamin C framework to make cryptography code healthy.
§Bounded Random Numbers
The BoundedRng
trait provides a way to generate random numbers within a specific range.
use vitaminc_random::{BoundedRng, SafeRand, SeedableRng};
let mut rng = SafeRand::from_entropy();
let value: u32 = rng.next_bounded(10);
assert!(value <= 10);
Or using a Protected
value:
use vitaminc_protected::{Controlled, Protected};
use vitaminc_random::{BoundedRng, SafeRand, SeedableRng};
let mut rng = SafeRand::from_entropy();
let value: Protected<u32> = rng.next_bounded(Protected::new(10));
assert!(value.risky_unwrap() <= 10);
§CipherStash
Vitamin C is brought to you by the team at CipherStash.
License: MIT
Structs§
- Safe
Rand - A secure random number generator that is safe to use for cryptographic purposes.
Enums§
Traits§
- Bounded
Rng - A trait for generating random numbers within a specific range.
- Fill
- Types which may be filled with random data
- Generatable
- A trait for types that can be generated randomly.
The random number generator is passed as an argument to the
generate
method and must implement theSafeRand
trait. - RngCore
- The core of a random number generator.
- Seedable
Rng - A random number generator that can be explicitly seeded.