Generate a nonce suitable for secret key encryption.
Generate a key suitable for secret key encryption.
Wrapper around crypto_secretbox_open_easy. Decrypts a cipher using a nonce and key and returns the decrypted message. If decryption fails, null is returned.
Wrapper around crypto_secretbox_open_easy that decrypts in place. buffer is changed in place from the cipher to the decrypted message. If decryption is successful, true is returned and buffer is updated with the length of the decrypted message, which will be shorter than the cipher. Otherwise true will be returned.
Wrapper around crypto_secretbox_easy. Encrypts a message using a nonce and key and returns the cipher with MAC as a prefix.
Wrapper around crypto_secretbox_easy that encrypts in place. buffer is changed in place from the message to the cipher. Note that it will be reallocated to be large enough to include the MAC, which may cause the array to be copied.
Decrypt box which contains the ciphertext and the nonce used to generate it. If decryption fails it returns null.
Encrypt message using key and a newly generated nonce. Return a SecreBox with the encrypted ciphertext and the generated nonce.
A struct containing both the encrypted cipher (using secret key encryption) and the nonce used to encrypt it.