Я использую следующий код для расшифровки pgp-сообщений, но консоль выдает ошибку.Ключи PGP и пароль совпадают.помогите, пожалуйста, я не могу заставить его работать и правильно расшифровываю мои pgp сообщения
const openpgp = require('openpgp') // use as CommonJS, AMD, ES6 module or via window.openpgp
let res = undefined;
export const Decrypt = async function(props) {
openpgp.initWorker({ path:'openpgp.worker.js' }) // set the relative web worker path
const pubkey =
`-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: BCPG C# v1.6.1.0
-----END PGP PUBLIC KEY BLOCK-----`;
// put keys in backtick (``) to avoid errors caused by spaces or tabs
const privkey =
`-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: BCPG C# v1.6.1.0
-----END PGP PRIVATE KEY BLOCK-----`;
const passphrase = "matchingpassword";
const privKeyObj = (await openpgp.key.readArmored(privkey)).keys[0]
await privKeyObj.decrypt(passphrase)
const options = {
message: await openpgp.message.readArmored(props.msg), // parse armored message
publicKeys: (await openpgp.key.readArmored(pubkey)).keys[0], // for verification (optional)
privateKeys: privKeyObj // for decryption
}
return openpgp.decrypt(options);
}
//encryptFunction({msg: 'test'});
сообщение об ошибке:
openpgp.js:35010 Uncaught (in promise) Error: Error decrypting message: Session key decryption failed.
at Message.decryptSessionKeys (openpgp.js:35010)
at async Message.decrypt (openpgp.js:34879)
Message.decryptSessionKeys @ openpgp.js:35010
Promise.then (async)
asyncGeneratorStep @ asyncToGenerator.js:13
_next @ asyncToGenerator.js:25
(anonymous) @ asyncToGenerator.js:32
(anonymous) @ asyncToGenerator.js:21
success @ index.js:293
fire @ jquery.js:3291
fireWith @ jquery.js:3421