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?
The cipher
value is supposed to be a string describing the algorithm to use, not an instance of a Cipher
object.
For reference, see the default cipher value and the value passed to the plugin instantiation call for the unit tests .
In your code, try using this:
bookshelf.plugin(encryptColumns, {
cipher: 'aes-256-cbc',
key: config.encrypt.aesKey
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.