Git Product home page Git Product logo

seeder's Introduction

rand_seeder

Build Status Latest version Documentation Minimum rustc version License

A universal seeder based on SipHash.

This crate is designed for use with the rand crates, allowing any RNG supporting rand_core::SeedableRng to be seeded from any hashable value. It provides the following:

  • SipHasher is a portable implementation of SipHash-2-4. According to the authors, SipHash is a secure, fast and simple keyed hash function.
  • SipRng is a PRNG based on the SipHash state and mixing operations. It is statistically high-quality, passing practrand tests to at least 4 TiB.
  • SipHasher::into_rng() transitions a SipHasher into a SipRng, maintaining the full 256 bits of state. (This might break the hasher's security.)
  • Seeder is a convenience wrapper around the above (see example).

Seeding is designed to be fast, robust, flexible and portable. This library is intended for use in simulations and games, allowing e.g. any keyword to reproduce a simulation or procedurally generated world.

This library is not intended for cryptographic applications, and definitely not for password hashing.

Example:

use rand_core::RngCore;         // for next_u32
use rand_pcg::Pcg64;            // or whatever you like
use rand_seeder::Seeder;

let mut rng: Pcg64 = Seeder::from("stripy zebra").make_rng();
println!("First value: {}", rng.next_u32());

Changelog

Rust version requirements

Requires rustc 1.32 or greater for the .to_le_bytes() method and for rand_core 0.5 compatibility.

License

rand_seeder is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

seeder's People

Contributors

dhardy avatar ralfjung avatar

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.