Function sodiumoxide::randombytes::randombytes_buf_deterministic [−][src]
pub fn randombytes_buf_deterministic(size: usize, seed: &Seed) -> Vec<u8>
Expand description
WARNING: you should only use this function for testing purposes or a known good use case
in which it is acceptable to rely on the secrecy of the seed passed to
randombytes_buf_deterministic
. The function is (as its name suggests) entirely deterministic
given knowledge of the seed. It does not incorporate entropy of any form and should almost
never be used for cryptographic purposes. If you need to generate a deterministic stream of
cryptographic quality pseudo random data you’re better suited using a stream cipher directly
e.g. one of the stream ciphers exposed in sodiumoxide::crypto::stream
or
the higher level secretstream
API.
The randombytes_buf_deterministic
function stores size bytes into buf indistinguishable from
random bytes without knowing seed. For a given seed, this function will always output the same
sequence; size can be up to 2^38 (256 GB).
Seed is SEEDBYTES
bytes long.
This function is mainly useful for writing tests, and was introduced in libsodium 1.0.12. Under the hood, it uses the ChaCha20 stream cipher. Up to 256 GB can be produced with a single seed.