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

我想知道我是否做错了。也许有人有一个主意。亲切的问候

马克斯

消息形式dev:"停止在解密选项对象中传递密码。这是针对使用密码加密的消息(对称密钥加密(而不是您正在使用的公共密钥加密。因为您提供的密码认为它正在使用以前的模式。"

相关内容

最新更新