I want to encrypt a text file with bank details and want some specific user or team can decrypt those with the private key. How to achieve this using PGP.

2 Answers 2


Apex has no facilities to do PGP encryption or decryption, and it's unlikely that you'd be able to write your own implementation (which is a terrible idea in general) because the crypto support in Apex is very limited and the governor limits are restrictive.

Don't mess with cryptography unless you have expert-level knowledge of the math involved.

It sounds like you may want to look at Shield Platform Encryption instead.

  • Shield Platform Encryption won't accomplish the goal here IMOP Mar 23 at 15:58

In theory, you could store key pairs in a custom setting or custom object text field and use a JavaScript library in the browser with an LWC Component (https://github.com/openpgpjs/openpgpjs)

I can't remember if there is a limitation on using a JS library like OpenPGPJS in an LWC - I haven't tried it.

Otherwise, write a service in Java/Python/etc. and do a request & reply to encrypt/decrypt the messages.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .