Encode and Decode String for security reason in SAP

 SAP provides standard Utility class CL_HTTP_UTILITY which provides methods that can be used to encode and decode string for security reasons.


PARAMETERS p_string TYPE string.

DATA lv_encode_str TYPE string,                        

           lv_decode_str TYPE string.

WRITE :‘Plain String :’p_string.

CALL METHOD cl_http_utility=>if_http_utility~encode_base64   EXPORTING     unencoded p_string    ” Unencoded String   RECEIVING     encoded   lv_encode_str.    ” BASE64-Encoded String

WRITE :‘Encoded String:’lv_encode_str COLOR 5.

CALL METHOD cl_http_utility=>if_http_utility~decode_base64   EXPORTING     encoded lv_encode_str    ” BASE64-Encoded String   RECEIVING     decoded lv_decode_str.    ” Decoded string


WRITE :‘Decoded Sing:’lv_decode_str COLOR 3.


 Here is the program. Execute.

 Run.


 

 

2 comments

  1. Its an old post but NEVER encode data as base64 for securitry reason. Thats not save, everyone with a little bit of understanding decodes that stuff online in seconds (google base64 decoder). Its as safe as storing the data in plain text. If you want to encode for security reasons, please use AES 256 bit.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s