// default aes-128-ecb
const data = { a: 1, b: [1, 2, 3] };
const key = '1234567812345678';
const encrypted = aesEncrypt(data, key);
const decrypted = aesDecrypt(encrypted, key).toString('utf8');
console.log('encrypted:', encrypted, 'decrypted: ', decrypted);
// aes-128-cbc
const data = { a: 1, b: [1, 2, 3] };
const key = '1234567812345678';
const iv = Buffer.alloc(16, 0);
const algorithm = 'aes-128-cbc';
const encrypted = aesEncrypt(data, key, algorithm, iv);
const decrypted = aesDecrypt(encrypted, key, algorithm, iv).toString('utf8');
console.log('encrypted:', encrypted, 'decrypted: ', decrypted);
aes 加密