JS-Rijndael
JS-Rijndael is a port of F. Doering and B. Poettering implementation of Rijndael algorithm. It has no external dependencies and is fully compatible with mcrypt.
How to use
Add the dependency to your project: npm install --save js-rijndael
.
Require it in your file.
var mcrypt = ;
mcrypt.listAlgorithms()
lists the available ciphers:
- rijndael-128
- rijndael-196
- rijndael-256
mcrypt.listModes()
lists the available modes:
- ecb
- cbc
- cfb
- ncfb
- nofb
- ctr
Two methods are exposed: Encrypt
and Decrypt
. They take byte arrays as inputs (regular arrays).
Encrypt
encryptedByteArray = mcrypt;
Decrypt
clearByteArray = mcrypt;
Example
var base64 = ; var key = slice;var iv = slice;var message = slice;var clearText = StringfromCharCode; console;
Tests
Generate test data
Two solutions:
- With
php
andmcrypt
, runphp generateTests.php > ../test-data.js
- With
docker
, run./generateTests.sh
Run tests
With the test data generated, run npm test
.