Module Crypto_box.Secretbox

type key
val unsafe_of_bytes : Stdlib.Bytes.t -> key
val secretbox : key -> Stdlib.Bytes.t -> nonce -> Stdlib.Bytes.t

secretbox key msg nonce encrypts and authenticates the data in msg using key and nonce and returns the authentication tag and the ciphertext in one buffer. For this reason, the returned buffer will be tag_length longer than msg.

val secretbox_open : key -> Stdlib.Bytes.t -> nonce -> Stdlib.Bytes.t option

secretbox_open key cmsg nonce verifies and decrypts cmsg using key and nonce and returns the plaintext if successful. As above, the returned buffer will be tag_length shorter than cmsg.