#random #seeder #password-hashing

no-std rand_seeder

A universal random number seeder based on SipHash

5 releases

Uses old Rust 2015

0.2.3 Feb 23, 2022
0.2.2 Dec 23, 2020
0.2.1 May 28, 2020
0.2.0 Nov 13, 2019
0.1.0 Oct 15, 2019

#972 in Algorithms

Download history 3181/week @ 2023-12-13 2276/week @ 2023-12-20 1651/week @ 2023-12-27 3273/week @ 2024-01-03 3926/week @ 2024-01-10 3629/week @ 2024-01-17 3542/week @ 2024-01-24 3804/week @ 2024-01-31 5153/week @ 2024-02-07 4561/week @ 2024-02-14 4576/week @ 2024-02-21 3824/week @ 2024-02-28 4173/week @ 2024-03-06 8934/week @ 2024-03-13 8386/week @ 2024-03-20 3789/week @ 2024-03-27

25,776 downloads per month
Used in 66 crates (31 directly)

MIT/Apache

26KB
497 lines

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.

Dependencies

~50KB