Invalid key length in crypto.createCipheriv

Just add a tip: Key length is dependent on the algorithm, such as for aes192, it’s 24 bytes, or aes256, it’s 32 bytes.
You need to have a key length of 32 byte (256 bit).
So if you change your key line to:

let key = crypto.createHash('sha256').update(String(secret)).digest('base64').substr(0, 32);

it will work.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)