Tuesday 26 April 2022

How to Encode a string to Base64 format in Apex

 Hi ,

Here we are going to learn how to encode a string to Base64 format in Apex 

Eg:

String urlparam = 'Salesforce Techbook';

String urlString = EncodingUtil.base64Encode(Blob.valueof(urlparam));

System.debug(urlString);

Output: U2FsZXNmb3JjZSBUZWNoYm9vaw==


Reference: 

https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_restful_encodingUtil.htm

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_encoding.htm


No comments:

Post a Comment

Best Practices for Building Prompt Templates

 Hi, The following best practices should be considered when building prompt templates: Make sure that your prompt templates are concise and ...