diff --git a/test/sodium.tests.ts b/test/sodium.test.ts similarity index 93% rename from test/sodium.tests.ts rename to test/sodium.test.ts index 74524b2..cafa577 100644 --- a/test/sodium.tests.ts +++ b/test/sodium.test.ts @@ -138,4 +138,14 @@ test("crypto_kx", () => { expect(clientKeys.rx).toEqual(serverKeys.tx); expect(clientKeys.tx).toEqual(serverKeys.rx); +}); + +test("crypto_secretbox", () => { + let message = sodium.from_string('Science, math, technology, engineering, and compassion for others.'); + let key = sodium.crypto_secretbox_keygen(); + let nonce = sodium.randombytes_buf(sodium.crypto_secretbox_NONCEBYTES); + + let ciphertext = sodium.crypto_secretbox_easy(message, nonce, key); + let decrypted = sodium.crypto_secretbox_open_easy(ciphertext, nonce, key); + expect(decrypted).toEqual(message); }); \ No newline at end of file