+ Start a Discussion

AES private key

Is it possible to share an AES key between Salesforce and another application? I know there is the Crypto.generateAesKey() method, but I can't use that key in a PHP application to decrypt the data later. Is it possible to generate my own AES key from a string, then use that string as the AES key in both applications?


Hi, Did you find an answer? I'm also looking for a solution for this.




You could do:

Blob key = Blob.valueOf('This is the key.....'); // Make it 16 Bytes or required


and then 

String myStringToEncrypt = 'This is my String....'

Blob myBlobData = Blob.valueOf(myStringToEncrypt)

Blob myEncryptedString = Crypto.encryptWithManagedIV('AES256', key, myBlobData);


Jia HuJia Hu
I really want to know how to create a 16 Bytes Key.
Anyone can help?

Not sure what other ways exist but I used the following code and just kept changing the text until the size of the blob was the desired size.


blob cryptoKey = blob.valueOf('ABC123');
system.debug('--------------------------cryptoKey.size():' + cryptoKey.size());