Node.js and crypto library

By : Mike

I'm having weird issues with Node's crypto library. I wrote this simple AES testing script:

var cipher = crypto.createCipher('aes-256-cbc','InmbuvP6Z8')
var text = "123|123123123123123";
var crypted ='hex')
var decipher = crypto.createDecipher('aes-256-cbc','InmbuvP6Z8')
var dec ='utf8')

When I do console.log(dec), it's null. For some reason if I set test to "123|123123", it works. So why does "123|123123" work but "123|123123123123123" doesn't?

By : Mike


Please note that the = operator will not work in later versions of node.js. Please follow the advice given in Node.js Crypto class returning different results with updated version and use Buffer.concat()

This video can help you solving your question :)
By: admin