*&---------------------------------------------------------------------*
*& Report ZLEIY_ABAP_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZLEIY_ABAP_TEST.
DATA: ENCRYPTOR TYPE REF TO CL_HARD_WIRED_ENCRYPTOR,
CX_ERROR TYPE REF TO CX_ENCRYPT_ERROR.
DATA: STRING TYPE STRING VALUE 'Welcome to SAP family',
XSTRING TYPE XSTRING,
V_MSG TYPE STRING,
V_DESTRING TYPE STRING,
V_ENSTRING TYPE STRING.
START-OF-SELECTION.
CREATE OBJECT ENCRYPTOR.
TRY.
CALL METHOD ENCRYPTOR->ENCRYPT_STRING2STRING
EXPORTING
THE_STRING = STRING
RECEIVING
RESULT = V_ENSTRING.
CATCH CX_ENCRYPT_ERROR INTO CX_ERROR.
CALL METHOD CX_ERROR->IF_MESSAGE~GET_TEXT
RECEIVING
RESULT = V_MSG.
MESSAGE V_MSG TYPE 'E'.
ENDTRY.
WRITE: V_ENSTRING.
SKIP.
TRY.
CALL METHOD ENCRYPTOR->DECRYPT_STRING2STRING
EXPORTING
THE_STRING = V_ENSTRING
RECEIVING
RESULT = V_DESTRING.
CATCH CX_ENCRYPT_ERROR INTO CX_ERROR.
CALL METHOD CX_ERROR->IF_MESSAGE~GET_TEXT
RECEIVING
RESULT = V_MSG.
MESSAGE V_MSG TYPE 'E'.
ENDTRY.
WRITE: V_DESTRING.
SKIP.
PS:这种加密解密安全新不高哦,别人可以用ABAP反解密。