randombytes_buf()
for every message encrypted with the same key without having to worry about a collision.crypto_stream
operation.crypto_stream()
function stores clen
pseudo random bytes into c
using a nonce n
(crypto_stream_NONCEBYTES
bytes) and a secret key k
(crypto_stream_KEYBYTES
bytes).crypto_stream_xor()
function encrypts a message m
of length mlen
using a nonce n
(crypto_stream_NONCEBYTES
bytes) and a secret key k
(crypto_stream_KEYBYTES
bytes).c
. The ciphertext is the message combined with the output of the stream cipher using the XOR operation, and doesn't include any authentication tag.m
and c
can point to the same address (in-place encryption/decryption). If they don't, the regions should not overlap.k
.randombytes_buf()
but improves code clarity and can prevent misuse by ensuring that the provided key length is always be correct.crypto_stream_KEYBYTES
crypto_stream_NONCEBYTES
crypto_stream_PRIMITIVE