I have requirement to encrypt the password that is stored in Named Credentials when making call out to external system.

So I'm planning to use AES256 encryption algorithm from crypto class. But is it possible to apply this algorithm on namedCredentials?

  • Rama, why do you want to encrypt Naming credentials? Salesforce manages them so that you don't need to.
    – ytiq
    Commented Dec 27, 2019 at 11:53
  • I believe if I do not encrypt the password, external application to which I'm making callout receives the password in plain text format, also 'in transit' password will be in unencrypted format. Our external application wants to receive the password in encrypted format, so they can decrypt it and authorize the user.
    – Rama
    Commented Dec 27, 2019 at 18:07

1 Answer 1


No you cannot encrypt them. In order to complete the flow you would need the correct unencrypted password. Additionally there is no functionality to use the merge fields or normal process where you would be able to decrypt.

If you must encrypt them you will need to use custom metadata or custom settings and build the oAuth process yourself.

Be aware that users with customize application permission can view named credentials, so if your security policy requires that the secrets be hidden from subscribers, then please use a protected custom metadata type or protected custom setting

Storing Sensitive Data

You must log in to answer this question.

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