That's the code that I'm using.
`function decryptData(encryptData){
let result;
let sync = true;
const encryptDecryptFunction = async() => {
console.log('working');
var privKeyObj = (await openpgp.key.readArmored(current_secret)).keys[0];
await privKeyObj.decrypt(current_pass);
const options = {
message: openpgp.message.fromText(encryptData), // input as Message object
privateKeys: [privKeyObj]
}
openpgp.decrypt(options).then(plainText => {
result = plainText.data // '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
sync = false;
}).catch((err) => {
console.log(err);
result = false;
sync = false;
})
}`
You probably need message.readArmored instead of message.fromText - please see the examples in the README ;)
You probably need
message.readArmoredinstead ofmessage.fromText- please see the examples in the README ;)
I did that now I get this error ' Parameter [message] needs to be of type Message or CleartextMessage'
You probably need to add an await before it ^.^
You probably need to add an
awaitbefore it ^.^
const options = {
message: await openpgp.message.readArmored(encryptData), // input as Message object
privateKeys: [privKeyObj]
}
that's my finale code and it stills give me the ' Parameter [message] needs to be of type Message or CleartextMessage'
That's.. strange. I'm not sure how that could happen. And that code works for me. I'm tempted to say, are you sure you're running the new code? Maybe that error is coming from somewhere else?
Can you send the function that you have been using ?
See e.g. https://github.com/openpgpjs/openpgpjs#encrypt-and-decrypt-string-data-with-pgp-keys