Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

epoch_rng

Crates.io Documentation

A lightweight psudo random number generator library for Rust featuring:

• Epoch‑seeded RNG
• Configurable Linear Congruential Generator (LCG)
• Simple API
• No external dependencies

This crate is intended for lightweight simulations, games, and experimentation where a fast and simple RNG is useful.

⚠️ Not cryptographically secure.


Installation

cargo add epoch_rng

Usage

use epoch_rng::epoch_rng::EpochRng;

fn main() {
    let mut rng = EpochRng::new();

    println!("u64: {}", rng.next_u64());
    println!("u32: {}", rng.next_u32());
    println!("f64: {}", rng.next_f64());

    println!("range f64: {}", rng.gen_range(1.0, 10.0));
}

Shuffle Example

use epoch_rng::epoch_rng::EpochRng;

fn main() {
    let mut rng = EpochRng::new();

    let mut data = [1,2,3,4,5];
    rng.shuffle(&mut data);

    println!("{:?}", data);
}

LCG RNG

use epoch_rng::lcg_rng::LcgRng;

fn main() {
    let mut rng = LcgRng::new();

    println!("{}", rng.next_u64());
}

Features

Current RNG implementations:

EpochRng – seeded from system epoch time
LcgRng – configurable linear congruential generator

Both support:

  • next_u64
  • next_u32
  • next_f64
  • range generation
  • shuffling

Future Plans

Possible improvements:

  • no_std support
  • additional algorithms (XorShift, PCG, Xoshiro)

About

Simple epoch‑based PRNG and configurable LCG PRNG written in rust and is now available as crate!

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages