简体   繁体   中英

OpenPGP.JS: Error while decrypting a message

I try to decrypt a message by using OpenPGP.JS. I always get this Error:

Unhandled promise rejection (rejection id: 1): Error: Error decrypting   
message: No symmetrically encrypted session key packet found.

This is my code:

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!'
});

I wonder want I'm doing wrong. Maybe somebody has an idea. Kind regards

Markus

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

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM