I am trying to use Bookshelf-encrypted-columns for aes encrypt my data, for that I need key, and cipher. Key is not a problem but while creating "cipher" I am getting this error below:
"Error: Invalid cipher: 78c2527b394d0d4016571fea85e40c52"
Code below requires cipher:
bookshelf.plugin(encryptColumns, {
cipher: getCipher(config.encrypt.aesKey),
key: config.encrypt.aesKey
});
Function that creates cipher using nodejs crypto createCipheriv
function getCipher (key) {
// generate initialization vector
let iv = new Buffer.alloc(16); // fill with zeros
// encrypt data
return crypto.createCipheriv('aes-256-cbc', key, iv);
}
Is there a solution to create cipher?