gpt4 book ai didi

node.js - Node JS错误: Invalid cipher

转载 作者:太空宇宙 更新时间:2023-11-04 00:08:55 24 4
gpt4 key购买 nike

我正在尝试使用Bookshelf-encrypted-columns对于 aes 加密我的数据,为此我需要 key 和密码。 key 不是问题,但在创建“密码”时,我收到以下错误:

"Error: Invalid cipher: 78c2527b394d0d4016571fea85e40c52"

下面的代码需要密码:

bookshelf.plugin(encryptColumns, {
cipher: getCipher(config.encrypt.aesKey),
key: config.encrypt.aesKey
});

使用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);
}

有创建密码的解决方案吗?

最佳答案

cipher 值应该是描述要使用的算法的字符串,而不是 Cipher 对象的实例。

有关引用,请参阅the default cipher valuethe value passed to the plugin instantiation call for the unit tests .

在您的代码中,尝试使用以下内容:

bookshelf.plugin(encryptColumns, {
cipher: 'aes-256-cbc',
key: config.encrypt.aesKey
});

关于node.js - Node JS错误: Invalid cipher,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50899662/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com