We want to store some integration passwords in Salesforce so that it can be accessible when we access that system. Just trying to understand what approach we should take to store these credentials in salesforce.

FYI - I am aware of encrypted fields in SFDC (but looking if there is any other options).


I've handled a similar situation in the past through a combination of text/text area custom fields, apex and visualforce.

The text/textarea is used to store an encrypted version of the data. The visualforce page allows the user to type in the secret key that is used to view or save that data, and the apex controller actually carries out the encrypt before storing against the record and the decrypt when retrieving.

The reason I went that route is I didn't want every administrator to be able to access the plaintext data, which encrypted fields will allow. The downside is that if the secret key is forgotten or mislaid, its not possible to decrypt the data, so you need to make sure you have a process in place to manage the key.

The actual Apex is pretty straightforward. If these are being used in an automated fashion you could store the key in code, although this means it is still decryptable if someone goes to the effort of writing some additional apex to use the key.

| improve this answer | |
  • 3
    You can store the key in a custom setting, which if protected and in a managed package, would be unavailable to anyone outside of the packaging org. Using the managed IV options, you can also avoid having to store the IV separately, which overall makes a good fit for keeping secrets secret. – sfdcfox Nov 6 '13 at 17:28
  • The comment here should be the answer. – Nicholas DiPiazza Jan 1 '15 at 21:55
  • What if you are not writing code in a managed package? Is there a solution that allows for code in the same instance to access it securely? – Chris Jan 15 '16 at 3:31
  • @Chris I think it's a question of, "Do you need the key to the door, or do you need the door opened for you on demand?" I'm looking into this because I want to set up Apex code that pushes to Pardot's API, which requires logging into Pardot over that same API. The credentials have to go somewhere. But I'm willing to merely expose a wrapper "push to Pardot" class/method "globally" (instance-wide, outside the managed package). My "calling" code doesn't need to know the credentials - it just has to be able to get data to Pardot. – k.. Jun 23 '16 at 21:06

Aside from using the existing encrypted fields the only option really would be to roll the encryption/decryption yourself, of course given the governor limits at play anything super intensive would be out of the question.

I'd say your best bet is to use those fields, or if possible, leverage OAuth authentication so you're only having to store a valid token.

| improve this answer | |
  • 3
    Encryption is built into the platform, so there's no need to try anything "super-intensive"-- you can get AES256 in milliseconds of processing time. – sfdcfox Nov 6 '13 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.