Skip to Content
Technical Articles
Author's profile photo Tom Young

How to do RSA signature and Base64 by UDF for SAP PO

While doing integration with some soap/rest receiver through SAP PI/PO, they may ask to do RSA signature and Base64 encoding for some of the fields.

The soap/rest receiver should provide the private key to the sender.  When they receive any message with RSA signature by a private key, they will use their own public key to verify the private key to check if the data is sent from a legal sender.

For this kind of requirements, we can do in SAP PI/PO by using Java mapping or UDF.

In this post, I will explain how to use UDF to do RSA signature and Base64.


Before the mapping, the soap/rest receiver should provide the private key to SAP PO.

We are starting at the message mapping as below. (DT MT and SI creation steps are skipped)message%20mapping

Figure 1:message mapping

Create the UDF privateKeyEncrypt as below.

Figure 2:UDF

The code attached:

public String privateKeyEncrypt(String str, String privateKey, Container container) throws StreamTransformationException{

try {


byte[] decoded = Base64.getDecoder().decode(privateKey);

PrivateKey priKey = KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded));


Cipher cipher = Cipher.getInstance("RSA");

cipher.init(Cipher.ENCRYPT_MODE, priKey);

String outStr = Base64.getEncoder().encodeToString(cipher.doFinal(str.getBytes()));

return outStr;

}  catch (Exception e) {

throw new StreamTransformationException(e.getMessage());



Use the UDF for the segment sign. The 2nd input Constant should be the private key provided by the receiver.

Figure 3: field mapping


The string abc will be encrypted and base64 to a different string as below.

Figure 4: test result

Please share your feedback or thoughts in a comment

And you can follow the SAP Process Orchestration environment Topic page (,
Post and answer questions about SAP Process Orchestration (,
and read other posts on the topic (

For similar content, please follow my profile(SAP People) and I will try to post more in the future.


Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.