In Einstein Playground app developed by the Salesforce Lab, I have uploaded the einstein platform service private key file named einstein_platform.pem to complete my einstein platform service setup. And the account has been setup successfully and the app is working properly.

Now I am trying to get access token of einstein platform service through Apex code provided by the Metamind. And when I am trying to get the VersionData of the 'einstein_platform' titled file which I haved uploaded earlier, I got a base64 formed blob data. But when I am going to convert this blob data into original string, I am getting this error :

BLOB is not a valid UTF-8 string

ContentVersion base64Content = [SELECT Title, VersionData 
                                    FROM ContentVersion 
                                    where Title='einstein_platform'
                                    LIMIT 1];

String keyContents = base64Content.VersionData.tostring(); //this line is generating error

Later I have uploaded the einstein_platform.pem file with a different name named einstein_platform2.pem then checked and find out that the VersionData of the *'*einstein_platform'** titled file uploaded through the Einstein Playground app is different from the VersionData data of 'einstein_platform2' titled file.

  1. einstein_platform.pem file uploaded by me through the Einstein Playground app and giving the error while converting into original string

  2. einstein_platform2.pem file uploaded by me through Files tab and the version data is fine and okay to convert into original string

2 Answers 2


So may be the app named 'Einstein Playground' is somehow changing the blob data of 'einstein_platform.pem' file after uploading when uploading through the app. Uploading the same file outside of the app is okay and fine.

update :

Now I have downloaded the file 'einstein_platform.pem' which I uploaded through the app and I can see that the file is corrupted.

So, the app is encrypting the file after using it.

update :

I have found that the app is actually encrypting the 'einstein_platform.pem' file data with a SecretKey after uploading. The secret key can be found in the record of custom settings named 'Einstein Settings'. That custom settings is installed with the 'Einstein Playground' package.

May be the app is doing so for the security of the 'einstein_platform.pem' private-key.

Somehow I was able to decrypt the file data with that secret-key using 'AES128' algorithm.

ContentVersion base64Content = [select Title, VersionData 
                                from ContentVersion 
                                where Title = 'einstein_platform' 
                                limit 1
Blob secretKey = EncodingUtil.base64Decode('secret-key-found-in-the-custom-settings');  
Blob decryptedData = Crypto.decryptWithManagedIV('AES128', secretKey, base64Content.VersionData);

System.debug('decryptedData : ' + decryptedData.toString());
  • This was the same for me too - I had to download a whole new key Jun 5, 2020 at 7:48

Would calling the Apex EncodingUtil.base64Encode on it work? I have used that for other issues with Blob to string conversions.


  • 1
    Usually Apex EncodingUtil.base64Encode works. I have tried but it does not work for this scenario because the file data is corrupted and the blob is not a valid blob after uploading through the app. May 8, 2020 at 13:24

You must log in to answer this question.

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