DoxigAlpha

fill

Fills the buffer with random bytes.

Function parameters

Parameters

#
self:*Self
buf:[]u8

The seed must be uniform, secret and `secret_seed_length` bytes long.

Functions

#
init
The seed must be uniform, secret and `secret_seed_length` bytes long.
addEntropy
Inserts entropy to refresh the internal state.
random
Returns a `std.Random` structure backed by the current RNG.
fill
Fills the buffer with random bytes.

= 32

Values

#

Source

Implementation

#
pub fn fill(self: *Self, buf: []u8) void {
    var i: usize = 0;
    while (true) {
        const left = buf.len - i;
        const n = @min(left, rate);
        self.state.extractBytes(buf[i..][0..n]);
        if (left == 0) break;
        self.state.permuteR(8);
        i += n;
    }
    self.state.permuteRatchet(6, rate);
}