Warning: Use Cipheriv for counter mode of aes-256-ctr

I was having a similar issue and after running through this node issue and looking at the bottom of this section it looks like using aes-256-ctr without a random input to shake it up isn't recommended. After updating this to another algorithm the error went away.

I'm not sure which of your deps may be throwing this if you don't use crypto within your code. It may turn up searching for createCipher or aes-256-ctr.


for above warning use

var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'test@1234';
var iv = Buffer.from(Array.prototype.map.call(Buffer.alloc(16), () => {return Math.floor(Math.random() * 256)}));
var key = Buffer.concat([Buffer.from(password)], Buffer.alloc(32).length);
var cipher = crypto.createCipheriv(algorithm,password,iv)

in the createCipheriv method, we need to create one buffer for iv and one buffer for the key which contains password

instead of

var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'test@1234';
var cipher = crypto.createCipher(algorithm,password)

while converting your data to cipher. it will remove the warning

Tags:

Node.Js

Nextjs