This is an easy to use AES256 module for nodejs.
This module generates a random initialization vector each time the encrypt method is called. Furthermore, your shared key can be of any size because it is hashed using sha256.
Make sure you install and require the nodejs-aes256 module.
npm install nodejs-aes256
var aes256 = require('nodejs-aes256');
Ciphertext is base64 encoded. The first parameter is the shared key and the second is the plaintext.
var ciphertext = aes256.encrypt(key, plaintext);
For decryption, simply provide the shared key and ciphertext.
var plaintext = aes256.decrypt(key, ciphertext);
- This has only been tested with strings for the shared key and plaintext
- It does not detect if decryption has failed