Unable to decrypt with 5.0.0 "No public key encrypted session key packet found." #1421
-
I am attempting to decrypt a file that was created with this library using a public key to encrypt. I am able to decrypt the file using GPG Keychain but not this library. Encryption code (works just fine) const message = await createMessage({ text: input.toString() });
const publicKey = await readKey({ armoredKey: pgpKey });
const format = pipeConfig?.format ?? 'armored';
let result: Buffer;
if (format === 'binary') {
result = Buffer.from(
(
await encrypt({
message: message,
encryptionKeys: publicKey,
format
})
).buffer
);
} else if (format === 'armored') {
result = Buffer.from(
await encrypt({
message: message,
encryptionKeys: publicKey,
format
})
);
} Decryption code giving "Error: Error decrypting message: No public key encrypted session key packet found." const input = Files.readFileSync(...);
const message = await createMessage({ binary: input });
const decryptionKey = await readPrivateKey({ armoredKey: pgpKey });
const unencryptedFile = (
await decrypt({
message,
decryptionKeys: decryptionKey
})
).data.toString(); |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
This was my mistake. I was calling createMessage instead of readMessage when creating the message object to pass to the decrypt method. |
Beta Was this translation helpful? Give feedback.
-
Whoa, same mistake! Thanks for the help! |
Beta Was this translation helpful? Give feedback.
-
Got exactly the same issue, thanks for posting! |
Beta Was this translation helpful? Give feedback.
-
Got the same issue, Thank you so much, saved a lot of time! |
Beta Was this translation helpful? Give feedback.
This was my mistake. I was calling createMessage instead of readMessage when creating the message object to pass to the decrypt method.