#random #api #prng #generator #rand

randomorg

A random.org client library. The randomness comes from atmospheric noise, which for many purposes is better than the pseudo-random number algorithms typically used in computer programs.

10 releases (5 stable)

1.0.4 Feb 10, 2021
1.0.3 Feb 23, 2020
1.0.2 Jan 21, 2020
1.0.1 Sep 23, 2019
0.3.0 Jun 27, 2017

#703 in Cryptography

Download history 6/week @ 2023-11-06 4/week @ 2023-11-13 26/week @ 2023-11-20 36/week @ 2023-11-27 22/week @ 2023-12-04 16/week @ 2023-12-11 5/week @ 2023-12-18 25/week @ 2023-12-25 12/week @ 2024-01-01 6/week @ 2024-01-08 18/week @ 2024-01-15 10/week @ 2024-01-22 22/week @ 2024-01-29 5/week @ 2024-02-05 45/week @ 2024-02-12 245/week @ 2024-02-19

317 downloads per month
Used in jam_theme_picker

MIT license

67KB
1K SLoC

random.org

Build status Crates Docs MIT licensed

A https://random.org client library. The randomness comes from atmospheric noise, which for many purposes is better than the pseudo-random number algorithms typically used in computer programs.

Status

Everything is implemented. Note, that the random.org service API is at beta stage of development, however the library will try to be up-to-date.

The documentation

The documentation which may help you using this library.

Implementation

  • Immutable interface, no need to synchronize, thread-safe (Sync and Send).
  • No unsafe blocks.
  • reqwest crate is used for performing requests.
  • chrono for dates.
  • serde for serialization and deserialization.

Features

  • rand feature which provides the rand_core::RngCore trait implementation for the Random struct and adds new FallibleRandom<T: rand_core::RngCore> structure for better random generation UX.

Usage

Start by creating Random instance and perform needed operations after.

extern crate randomorg;

fn main() {
    use randomorg::Random;
    let r = Random::new("API KEY HERE");
    // A method-call way:
    println!("Result: {:?}", r.generate_integers(-100, 100, 15, true));
    // A lazy request builder way:
    let random_data = r.request_integers().min(0).max(100).limit(5).collect::<Vec<i32>>();
    println!("Random integers: {:?}", random_data);
}

With the rand feature you can also use it that way:

extern crate randomorg;

fn main() {
    use rand_core::RngCore;
    use randomorg::Random;
   
    let mut random = Random::new("API KEY HERE");
    let mut key = [0u8; 16];
    random.fill_bytes(&mut key);
    let random_u64 = random.next_u64();
}

License

This project is licensed under the MIT license.

Dependencies

~5–19MB
~271K SLoC