Module Crypto.Stream

Secret-key encryption.

The primitive is xsalsa20, NaCl documentation.

Keys and nonces

module Secret_key : sig ... end

Secret keys.

module Nonce : sig ... end

Nonces.

Cipher

val stream : secret_key:Secret_key.t -> nonce:Nonce.t -> length:int -> Bytes.t

stream ~secret_key ~nonce ~length generates a pseudo-random byte stream of length length based on secret_key and nonce. This can be xored with your plain or cipher text to encrypt or decrypt. xor does that directly for you.

val xor : secret_key:Secret_key.t -> nonce:Nonce.t -> stream:Bytes.t -> Bytes.t

xor ~secret_key ~nonce ~stream is the result of encrypting or decrypting stream using nonce and secret_key.