Skip to content

Commit

Permalink
test/sodium.tests.ts -> test/sodium.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 committed Jul 9, 2024
1 parent 4df3c46 commit 3dc1d30
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/sodium.tests.ts → test/sodium.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit 3dc1d30

Please sign in to comment.