I'm creating a digital signature for an integration and I've created a private/public key pair to sign the message. According to the Apex Crypto Class documentation,

This private key should not be hardcoded in the Apex script but should be stored in a protected custom setting or a encrypted fields in a custom table.

but the there's limit for the text fields, and the key obviously surpasses that.

I found a solution that involved splitting the key in and storing it in more than 1 field in the custom setting and then concatenate everything in the code; I don't find this solution extremely good because there are much more chances of something going wrong and consequently messing up the signature.

Does anyone have any other solution/idea?

Thanks in advance.


  • how many chars are in the key?
    – crmprogdev
    Aug 5, 2014 at 13:32
  • Encrypted fields have a limit of 175 characters. You're keys are really longer than that? Aug 5, 2014 at 18:26
  • Well, it's a RSA 1024-bit key, so it's pretty big. Thanks.
    – eclf
    Aug 6, 2014 at 14:11
  • Is it possible to store the key in a file/document and access it in my code? Can I read a .pem file in my code?
    – eclf
    Aug 7, 2014 at 10:57
  • Have you found a solution?
    – Sebastian
    Oct 12, 2016 at 9:35


Your Answer

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

Browse other questions tagged or ask your own question.