shr3 1.0.0

SHR3 - 3-shift register random number generator
Documentation
<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>
<h1>SHR3: 3-shift register random number generator</h1>

<p><a href="https://bues.ch/">https://bues.ch/</a></p>

<p><a href="https://bues.ch/cgit/shr3rs.git/">Git repository</a></p>

<p>The SHR3 generator can be used to generate non-crypto random bits with only very few computations.</p>

<p>It is suitable for running on very small and restricted hardware (e.g. small 8 bit microcontrollers).
The SHR3 function is evaluated once per extracted random bit. The LSB of the SHR3 state is extracted as output.</p>

<p>The generator has a cycle of approximately <code>4_000_000_000</code> bits.
Do not use it to extract large amounts of random bits (more than a hundred MiB or so),
unless you can tolerate looping back to the beginning of the random stream.
It will loop back to the beginning after <code>2**32 - 1</code> iterations.</p>

<p>This generator is <em>not</em> cryptographically secure! Do not use it for cryptographic applications.</p>

<h1>Example usage:</h1>

<pre><code>use shr3::prelude::*;

let mut shr3 = Shr3::new();                 // SHR3 with default seed (1).
let x: u8 = shr3.get();                     // Extract 8 bits from shr3.
let y: u16 = shr3.get_bits(10);             // Extract 10 bits from shr3 and store in lower bits of y.
assert_eq!(x, 0xF8);                        // Extracted random value.
assert_eq!(y, 0x2CC);                       // Extracted random value.

let mut shr3 = Shr3::new_state(42);         // SHR3 with custom seed (42).

let mut shr3: Shr3 = Default::default();    // Alternative to Shr::new().
</code></pre>

<h1>Example Cargo.toml dependencies</h1>

<p>Add this to your Cargo.toml:</p>

<pre><code>[dependencies]
shr3 = "1"
</code></pre>

<h1>no_std</h1>

<p>This crate does not require the Rust std library. It does not link to std.</p>

<h1>Optimized implementation</h1>

<p>This crate includes an optimized implementation for AVR 8-bit.</p>

<p>All other architectures use the generic implementation.
On most architectures, this generic implementation will be compiled to rather efficient code.</p>

<h1>License</h1>

<p>Copyright (c) 2022 Michael Buesch <a href="&#x6D;&#97;i&#108;&#x74;&#111;:&#109;&#64;&#98;u&#101;&#x73;&#46;&#x63;&#104;">&#109;&#64;&#98;u&#101;&#x73;&#46;&#x63;&#104;</a></p>

<p>Licensed under the Apache License version 2.0 or the MIT license, at your option.</p>
</body></html>