Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript OpenPGP.JS:解密消息时出错_Javascript_Node.js_Encryption_Openpgp.js - Fatal编程技术网

Javascript OpenPGP.JS:解密消息时出错

Javascript OpenPGP.JS:解密消息时出错,javascript,node.js,encryption,openpgp.js,Javascript,Node.js,Encryption,Openpgp.js,我尝试使用OpenPGP.JS解密消息。 我总是会遇到这样的错误: Unhandled promise rejection (rejection id: 1): Error: Error decrypting message: No symmetrically encrypted session key packet found. 这是我的代码: var openpgp = require('openpgp'); openpgp.initWorker({ path:'../node_m

我尝试使用OpenPGP.JS解密消息。 我总是会遇到这样的错误:

Unhandled promise rejection (rejection id: 1): Error: Error decrypting   
message: No symmetrically encrypted session key packet found.
这是我的代码:

var openpgp = require('openpgp'); 
openpgp.initWorker({ path:'../node_modules/openpgp/dist/openpgp.worker.js' }) 
var passphrase = 'Our secret approach'; //what the privKey is encrypted with

const fs = require('fs'); 
var data = fs.readFileSync('./order-file.txt', 'utf8');
var pubkey = fs.readFileSync('./public.key', 'utf8');
var privkey = fs.readFileSync('./privat.key', 'utf8');

var privKeyObj = openpgp.key.readArmored(privkey).keys[0];

options = {
        message: openpgp.message.readArmored(data),     // parse armored message
        publicKeys: openpgp.key.readArmored(pubkey),    // for verification (optional)
        privateKeys: openpgp.key.readArmored(privkey).keys[0].decrypt(passphrase),
        password : passphrase
    };

openpgp.decrypt(options).then(function(plaintext) {

    console.dir(plaintext);
    return plaintext.data; // 'Hello, World!'
});
我想知道我做错了什么。 也许有人有个主意。 问候


Markus

来自开发人员的消息:“停止在decryption options对象中传递密码短语。这是针对使用密码(对称密钥加密)而不是您正在使用的公钥加密进行加密的消息。因为您提供的是密码,它认为它使用的是前一种模式。”

是存储您的私钥的文件名,
privat.key
而不是
private.key
?是的,它是privat.key(我是德国人)。因此,所有文件都被读取。