[英]Node JS Error: Invalid cipher
I am trying to use Bookshelf-encrypted-columns for aes encrypt my data, for that I need key, and cipher.我正在尝试使用书架加密列对我的数据进行 aes 加密,为此我需要密钥和密码。 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使用 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. cipher
值应该是描述要使用的算法的字符串,而不是Cipher
对象的实例。
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
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.