Skip to content

Absolucy/rand-wyrand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rand-wyrand

This is a library that implements the WyRand PRNG for the RngCore trait from rand. It is completely #![no_std], and does not require the Rust standard library.

WyRand is an extremely fast, stable, and solid PRNG. While not cryptographically secure, it still passes the BigCrush and practrand tests, making it a solid choice for non-secure applications. (Basically, just don't use it to like, generate cryptographic keys or passwords or whatever)

Examples

Generate random number from 1 to 100

use rand::{Rng, SeedableRng};
use rand_wyrand::WyRand;

let mut wyrand = WyRand::from_entropy();
let mut bytes = [0_u8; 64];
wyrand.fill(&mut bytes);
println!("Random bytes: {bytes:?}");

Generate random bytes

use rand::{Rng, SeedableRng};
use rand_wyrand::WyRand;

let mut wyrand = WyRand::from_entropy();
println!("Random number from 1 to 100: {}", wyrand.gen_range(1..=100));

Generate random string

use rand::{distributions::Alphanumeric, Rng, SeedableRng};
use rand_wyrand::WyRand;

let mut wyrand = WyRand::from_entropy();
let rand_string: String = wyrand
	.sample_iter(&Alphanumeric)
	.take(16)
	.map(char::from)
	.collect();
println!("Random string: {rand_string}")

License

rand-wyrand is licensed under either the Apache License or the MIT License, at your choice.

License: Apache-2.0 OR MIT

Amendment

I, @Absolucy, fully give permission for any of my code (including the entirety of this project, rand-wyrand), anywhere, no matter the license, to be used to train machine learning models intended to be used for general-purpose programming or code analysis.

About

WyRand for Rust's `rand` crate

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE-Apache.md
MIT
LICENSE-MIT.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages