SAP Knowledge Base Article - Public

3267727 - How to encrypt a string with PDI

Symptom

You would like to encrypt a string with a keyed-hash authentication code via an ABSL script from your SAP Cloud Applications Studio add-on.

Environment

  • SAP Cloud Applications Studio
  • SAP Business ByDesign 

Cause

You may achieve this encoding or encryption of a string using ABSL, with the use of Hash.EncryptString() reuse library function, from library PlatinumEngineering.

The encoding alrorighitms "AES128", "AES192", "AES256" are supported.

Resolution

Please refer to the below sample code which you can try on your script:

import ABSL;

import AP.PlatinumEngineering;

 

var StringToBeEncrypted : XPEString;

StringToBeEncrypted = "test-123";

 

var Secretkey : XPEString;

Secretkey = "ExactlyThisLeng!" ; // the secretkey must have exactly this length

var EncryptedString = Hash.EncryptString("AES128",StringToBeEncrypted,Secretkey); // "AES128", "AES192", "AES256" can be used

Please be aware that the functions under PlatinumEngineering are internal functions from SAP so they are not revised by the documentation team yet and they are not released for general uses, hence they cannot be supported via incidents.

See Also

Please refer to the below blog for more details about the library:

https://blogs.sap.com/2017/09/25/sap-platinum-engineering-libraries/

Keywords

PDI, SDK, hash, EncryptString, PlatinumEngineering, reuse, library , KBA , AP-RC-BDS-SCR , ByDesign Studio Scripting (ABSL) , AP-XPE , Custom Specific Development , How To

Product

SAP Business ByDesign all versions ; SAP Cloud Applications Studio all versions