+ Start a Discussion
cstephenscstephens 

Base 64 Encode

I'm currently writing a mashup between my company's service and salesforce and I need to encode the data which I am sending to our service in base64, but I can't seem to figure out how to do this in Apex.  Can someone please point me in the correct direction.

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
cstephenscstephens

Actual solution to my issue is this:

 

String myBase64String = EncodingUtil.base64Encode(Blob.valueof(myString));

 

thanks for pointing me in the right direction.

All Answers

Novo ArtisNovo Artis

There is plenty on this in the Apex Code documentation. Have a look in there before starting a new thread, good luck.

cstephenscstephens

Thank you Simon, this is what I was attempting to do, but I didn't find the actual doc page for the EncodingUtils.... Problem I was having was that I was attempting to send a String to the function, and it takes a blob....  Now I need to figure out how to convert my string data into a blob....

cstephenscstephens

Actual solution to my issue is this:

 

String myBase64String = EncodingUtil.base64Encode(Blob.valueof(myString));

 

thanks for pointing me in the right direction.

This was selected as the best answer