This commit is contained in:
2025-03-05 16:41:58 +01:00
parent 512b827b40
commit b43894b58f
3 changed files with 141 additions and 1 deletions

25
tests/aead.test.js Normal file
View File

@ -0,0 +1,25 @@
const aead = require('../src/aead');
const crypto = require('crypto');
function generateRandomUint8Array(length = 16) {
const randomArray = new Uint8Array(length);
crypto.getRandomValues(randomArray);
return randomArray;
}
describe('aead.js functions', () => {
it('encrypt and decrypt', () => {
let msg = generateRandomUint8Array(28);
console.log(msg);
let ad = generateRandomUint8Array(12);
let iv = generateRandomUint8Array();
let key = generateRandomUint8Array();
let result = aead.keccakAEAD.encrypt(key, msg, iv, ad);
console.log(result.tag);
console.log(result.cipher);
let result2 = aead.keccakAEAD.decrypt(key, result.cipher, iv, ad);
console.log(result2.tag);
console.log(result2.plaintext);
});
});