[英]Using Node JS TLS passphrase and cipher options when creating a server and client using elliptic curve keys (no shared cipher suites error)
[英]Node JS Error: Invalid cipher
我正在嘗試使用書架加密列對我的數據進行 aes 加密,為此我需要密鑰和密碼。 密鑰不是問題,但在創建“密碼”時,我收到以下錯誤:
"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
對象的實例。
作為參考,請參閱默認密碼值和傳遞給單元測試的插件實例化調用的值。
在你的代碼中,嘗試使用這個:
bookshelf.plugin(encryptColumns, {
cipher: 'aes-256-cbc',
key: config.encrypt.aesKey
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.