The test/secretbox_easy2.c file
(in the sodium source code) shows how to use it:
randombytes_buf(nonce, sizeof nonce);
crypto_secretbox_easy(c, m, mlen, nonce, k);
crypto_secretbox_open_easy(decoded, c, mlen + crypto_secretbox_MACBYTES,
nonce, k);
In order to derive a key from a password, sodium provides crypto_pwhash_scryptsalsa208sha256
.