【问题标题】:OpenPGP.JS: Error while decrypting a messageOpenPGP.JS:解密消息时出错
【发布时间】:2017-09-18 11:47:59
【问题描述】:

我尝试使用 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!'
});

我想知道我做错了什么。 也许有人有一个想法。 亲切的问候

马库斯

【问题讨论】:

  • 是存储您的 privKey 的文件名,肯定是 privat.key 而不是 private.key
  • 是的,它是 privat.key(我是德国人)。所以所有文件都被读取了。

标签: javascript node.js encryption openpgp.js


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2021-01-22
    • 2019-07-14
    • 2022-10-24
    • 1970-01-01
    • 2016-02-28
    • 2011-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多