nanorand::rand::chacha

Type Alias ChaCha8

Source
pub type ChaCha8 = ChaCha<8>;
Expand description

The ChaCha CSPRNG, with 8 rounds.

Aliased Type§

struct ChaCha8 { /* private fields */ }

Implementations

Source§

impl<const ROUNDS: u8> ChaCha<ROUNDS>

Source

pub fn new() -> Self

Create a new ChaCha instance, seeding from the system’s default source of entropy.

Source

pub const fn new_key(key: [u8; 32], nonce: [u8; 8]) -> Self

Create a new ChaCha instance, using the provided key and nonce.

Trait Implementations

Source§

impl<const ROUNDS: u8> Clone for ChaCha<ROUNDS>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const ROUNDS: u8> Debug for ChaCha<ROUNDS>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const ROUNDS: u8> Default for ChaCha<ROUNDS>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const ROUNDS: u8> Display for ChaCha<ROUNDS>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const ROUNDS: u8> Rng<64> for ChaCha<ROUNDS>

Source§

fn rand(&mut self) -> [u8; 64]

Generates a random sequence of bytes, seeding from the internal state.
Source§

fn generate<Generated>(&mut self) -> Generated
where Generated: RandomGen<Self, OUTPUT>,

Generates a random of the specified type, seeding from the internal state.
Source§

fn fill_bytes<Bytes>(&mut self, buffer: Bytes)
where Bytes: AsMut<[u8]>,

Fill an array of bytes with randomness.
Source§

fn fill<Contents, Array>(&mut self, target: Array)
where Contents: RandomGen<Self, OUTPUT>, Array: AsMut<[Contents]>,

Fill an array with the specified type.
Source§

fn generate_range<Number, Bounds>(&mut self, range: Bounds) -> Number
where Number: RandomRange<Self, OUTPUT>, Bounds: RangeBounds<Number>,

Generates a random of the specified type, seeding from the internal state.
Source§

fn shuffle<Contents, Array>(&mut self, target: Array)
where Array: AsMut<[Contents]>,

Shuffle a slice, using the RNG.
Source§

impl<const ROUNDS: u8> SeedableRng<40, 64> for ChaCha<ROUNDS>

Source§

fn reseed(&mut self, seed: [u8; 40])

Re-seed the RNG with the specified bytes.