Friday 21 April 2017

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



via markus0074

No comments:

Post a Comment