The easy interface concatenates the ciphertext and the 16-byte long message authentication tag into a single buffer.
By default, these functions use the whole of pt and ct, but users can choose to only pass portions of these buffers, by passing some of these optional arguments:
pt_offset, ct_offset: start at the specified position in pt or ct (0 by default)
pt_len or ct_len: specify the number of bytes to take in pt or ct (by default, the entire buffer)
Note 1: Since it must always be the case that ct be 16 bytes longer than pt, functions accept only one of these arguments (pt_len for encryption functions, ct_len for decryption functions)
Note 2: As opposed to not passing pt_len at all, passing pt_len=0 will result in using an empty buffer.
box pt n pk sk ct authenticates and encrypts plaintext pt using public key pk, secret key sk, and nonce n and writes both the message authentication tag and the ciphertext in ct. Returns true if successful.
box_open ct n pk sk pt attempts to verify and decrypt ciphertext ct using public key pk, secret key sk, and nonce n and if successful writes the plaintext in pt and returns true.
box_afternm pt n ck ct authenticates and encrypts pt using shared key ck and nonce n and writes both the message authentication tag and the ciphertext in ct. Returns true if successful.
box_open ct n pk sk pt attempts to verify and decrypt ciphertext ct using shared key ck and nonce n and if successful writes the plaintext in pt and returns true.
secretbox pt n key ct authenticates and encrypts plaintext pt using secret key key and nonce n and writes both the message authentication tag and the ciphertext in ct. Returns true if successful.
secretbox_open ct n key pt attempts to verify and decrypt ciphertext ct using secret key key and nonce n and if successful writes the plaintext in pt and returns true.