REPORT zged_aes. DATA lv_message_string TYPE string. DATA lv_message_decrypted TYPE XSTRING. " create message DATA(lr_conv_sec) = cl_abap_conv_out_ce=>create( ). lr_conv_sec->write( data = 'This is my secret' ). " create key DATA(lr_conv_key) = cl_abap_conv_out_ce=>create( ). lr_conv_key->write( data = 'MySymmetricKey' ). " encrypt using AES256 cl_sec_sxml_writer=>encrypt( EXPORTING plaintext = lr_conv_sec->get_buffer( ) key = lr_conv_key->get_buffer( ) algorithm = cl_sec_sxml_writer=>co_aes256_algorithm_pem IMPORTING ciphertext = DATA(lv_message) ). WRITE LV_MESSAGE. " decrypt message cl_sec_sxml_writer=>decrypt( EXPORTING ciphertext = lv_message key = lr_conv_key->get_buffer( ) algorithm = cl_sec_sxml_writer=>co_aes256_algorithm_pem IMPORTING plaintext = lv_message_decrypted ). " convert xstring to string for output cl_abap_conv_in_ce=>create( input = lv_message_decrypted )->read( IMPORTING data = lv_message_string ). " output secret message WRITE:/ lv_message_string.