OpenPGP.JS: 解密消息时出错
OpenPGP.JS: Error while decrypting a message
我尝试使用 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!'
});
我想我做错了。
也许有人有想法。
亲切的问候
马库斯
来自开发者的消息:"Stop passing the passphrase in the decryption options object. That is for messages encrypted with a password (symmetric key encryption) not public key encryption, which you are using. Because you are supplying a password it thinks it's using the former mode."
我尝试使用 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!'
});
我想我做错了。 也许有人有想法。 亲切的问候
马库斯
来自开发者的消息:"Stop passing the passphrase in the decryption options object. That is for messages encrypted with a password (symmetric key encryption) not public key encryption, which you are using. Because you are supplying a password it thinks it's using the former mode."