How can I use aes encrption/decryption in api connect gateway script.. Below is the process i tried and the error I am getting help me understanding this issue
const crypto = require('crypto');
var encryptionKey = '0123456789abcd0123456789';
var iv = '12345678';
var plainText = 'Testing';
var cipher = crypto.createCipheriv('aes128-cbc',encryptionKey,Buffer.from(iv, 'utf8'));
var ciph = cipher.update(plainText,'utf8','hex');
consle.error(cipher.final('hex'));
Response ---Error "Named shared secret key '0123456789abcd0123456789' not found"
Can someone share me script for encryption and decryption for aes algorithm?
From the Node.Js Documentation
According to the documentation, the
keyandivmust both be either a UTF8 string, Buffer, TypeArray, or DataView. You may need to either change hekeyto a Buffer or the iv to a string.