We want to encrypt a text in Apex using provided key having 48 bytes.

Text = 'some xml';


How can we encrypt the text using the provided key? Salesforce supports AES128, AES192, AES256 algorithms for 16, 24, or 32 bytes respectively. But the private key which I have has 48 bytes and there is no equivalent algorithm in Salesforce for 48 bytes key. Would you please suggest me any workaround?

  • You need to find out exactly how the encryption is implemented on the other side of this integration. The key you provided (which I edited out; never include secret values here!) appears to be plain text rather than a hexadecimal representation. This makes me think it's likely being hashed to a different key size. AES is only defined for 128, 192, and 256-bit keys.
    – David Reed
    Commented Mar 1, 2018 at 13:59
  • @David, Thanks, The key which I mentioned is not the genuine. The other side of the integration system will use 3DES to decrypt. Does salesfroce support 3DES? Thanks!
    – user755806
    Commented Mar 1, 2018 at 14:31

1 Answer 1


Salesforce does not support 3DES. The only supported encryption algorithms in the Apex Crypto class are AES128, AES192, or AES256. An exception will be thrown if any algorithm value other than those three is provided.

You must log in to answer this question.

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