#security #numbers #secure-random #generator #generation #part

vitaminc-random

Secure Random Number Generation. Part of the Vitamin-C cryptographic suite.

2 releases

0.1.0-pre2 Sep 17, 2024

#730 in Cryptography

Download history 6/week @ 2024-10-12 133/week @ 2024-10-19 85/week @ 2024-10-26 98/week @ 2024-11-02 72/week @ 2024-11-09 125/week @ 2024-11-16 187/week @ 2024-11-23 186/week @ 2024-11-30 329/week @ 2024-12-07 275/week @ 2024-12-14 5/week @ 2024-12-21 29/week @ 2024-12-28 235/week @ 2025-01-04 196/week @ 2025-01-11 58/week @ 2025-01-18 14/week @ 2025-01-25

520 downloads per month
Used in 3 crates (via vitaminc-permutation)

MIT license

82KB
1.5K SLoC

Vitamin C Random

Crates.io Workflow Status

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

Dependencies

~2.6–3.5MB
~72K SLoC