1.0.12 • Published 3 years ago

aes-ccm v1.0.12

Weekly downloads
72
License
MIT
Repository
github
Last release
3 years ago

Build Status

aes-ccm

AES CCM module using OpenSSL

Installation

npm install aes-ccm --save

encrypt

const ccm = require('aes-ccm');

const key = Buffer.from('404142434445464748494a4b4c4d4e4f', 'hex');
const iv = Buffer.from('101112131415161718191a1b', 'hex');
const plain = Buffer.from('Secret message!', 'utf8');
const aad = Buffer.from('000102030405060708090a0b0c0d0e0f10111213', 'hex');
const tagLength = 16;

const res = ccm.encrypt(key, iv, plain, aad, tagLength);

console.log('ciphertext: ' + res.ciphertext.toString('hex'));
console.log('tag: ' + res.auth_tag.toString('hex'));

decrypt

const ccm = require('aes-ccm');

const key = Buffer.from('404142434445464748494a4b4c4d4e4f', 'hex');
const iv = Buffer.from('101112131415161718191a1b', 'hex');
const aad = Buffer.from('000102030405060708090a0b0c0d0e0f10111213', 'hex');
const ciphertext = Buffer.from('90f640f8b4e61c30d646b3a686dfe8', 'hex');
const tag = Buffer.from('d159ba0b957a1adc9b798cd9cb0d45c1', 'hex');

const dres = ccm.decrypt(key, iv, ciphertext, aad, tag);

console.log('ok: ' + dres.auth_ok);
console.log('plaintext: ' + dres.plaintext.toString('utf8'));

References

Copied from node-aes-ccm.

1.0.11

3 years ago

1.0.12

3 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.6

4 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

6 years ago

1.0.0

6 years ago