Hi guys I am wondering if anyone has experience using nodejs to decrypt using aes256.
The encrypted string is base64 encoded and the first 16 bytes has the IV.
I am trying to extract the IV like below but having problems:
var crypto = require('crypto'), algorithm = 'aes-256-cbc', key = '6IAVE+56U5t7USZhb+9wCcqrTyJHqAu09j0t6fBngNo='; function decrypt(text) { var buf = Buffer.from(text, 'base64'); var iv = buf.toString('binary', 0, 16); //console.log(iv.length); //var crypt = buf.toString('base64', 16); var decipher = crypto.createDecipheriv(algorithm, key, iv); decipher.setAutoPadding(false); var dec = decipher.update(crypt, 'base64', 'utf-8'); dec += decipher.final('utf-8'); return dec; } console.log(decrypt('mIBOVqk3bDCQPupFcIWNReXrdNRnb2P+iKl35yYRgbA=')); I keep getting the "Invalid IV Length" error.