Git Product home page Git Product logo

randlib's Introduction

Pseudo-random number generation library

randlib is a Rust library which allows generating pseudo-random numbers using a LFSR (Linear-feedback shift register).

Example

use randlib::{Random, RandomSeedSource};

fn main() {
    let src = RandomSeedSource::SystemTime;
    let mut rand = Random::new(src);
    
    println!("i32:  {}", rand.rand_i32());
    println!("u32:  {}", rand.rand_u32());
    println!("bool: {}", rand.rand_bool());
    println!("f32:  {}", rand.rand_f32());
}
Cargo.toml
[dependencies]
randlib = { git = "..." }

Features

  • libc
    • Enables RandomSeedSource::SystemTime and RandomSeedSource::Crand
    • Allows creating a seed value from the current system time as well as from the rand() function from libc.
  • posix
    • Enables RandomSeedSource::UrandomDev and RandomSeedSource::RandomDev
    • Allows creating a seed value by reading random bytes from /dev/urandom and /dev/random. These bytes are then used to create a u128 integer.
    • ⚠️ Since /dev/urandom and /dev/random only exist on *nix based systems, such as Linux and macOS, you should disable this feature.

By default both libc and posix are enabled.

The library should compile on Windows with default features, however using RandomSeedSource::UrandomDev and/or RandomSeedSource::RandomDev will crash your program!

⚠️ Warning

This library should not be used for cryptographic purposes!

randlib's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.