aes-cmac-js
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

AES-CMAC-JS

AES-CMAC implementation in pure javascript using sjcl. See RFC Spec.

For validation, this library contains passing test vectors taken from the RFC spec, see tests/test.ts.

Example

// pass your key here
const cmac = new AesCmac("0x2b7e151628aed2a6abf7158809cf4f3c");

// encrypt 0x000... using your key
const encrypted = cmac.encrypt(
  sjcl.codec.hex.toBits("0x00000000000000000000000000000000")
);
// expected output
const expected = sjcl.codec.hex.toBits("0x7df76b0c1ab899b33e42f047b91b546f");

// should be true
console.log(sjcl.bitArray.equal(t_0, aes_0));

Testing

You can easily fork and try out a live version of the code StackBlitz ⚡️

Package Sidebar

Install

npm i aes-cmac-js

Weekly Downloads

110

Version

1.0.2

License

MIT

Unpacked Size

103 kB

Total Files

11

Last publish

Collaborators

  • jfamousket