In my previous blog : Decode Base64 Incoming Encoded information in SAP XI/PI using Java Mapping I depicts how we can decode the incoming Encoded information by Java Mapping. We can achieve it by using Adapter Module[:)]
In this blog I will try to demonstrate how we can encode the payload in receiver Adapter before sending it to the destination.
SAP XI/PI has to pick a file from the input directory of the FTP server, once file picked by sender file adapter than it comes to IE for further processing (like transformation, routing etc). From the IE it goes to receiver adapter, the assigned custom module will be called, encode the data and send it to the destination.
Below is the method ModuleData that we have to implement.
Deploy the developed Adapter Module in the SAP J2EE engine using SDM, Visual Admin or by your favorite Java Editor SAP NWDS 
Once you successfully deployed the module in Engine, use it in the Module Tab of your SAP J2EE Sender/Receiver adapters.
I used JNDI name = EncodePayload so I have to use it in the Module tab also.
After successfully executing the interface, the encoded information will be sent to the receiver/destination.
Note: We can also use Encode/Decode classes from com.sap.aii.utilxi.base64.api.*;