首页 > 代码库 > ABAP 加密解密程序
ABAP 加密解密程序
用于对字符串的加密和解密:
DATA: o_encryptor TYPE REF TO cl_hard_wired_encryptor, o_cx_encrypt_error TYPE REF TO cx_encrypt_error. DATA: v_ac_string TYPE string VALUE ‘RICK‘, v_ac_xstring TYPE xstring, v_en_string TYPE string, v_en_xstring TYPE xstring, v_de_string TYPE string, v_de_xstring TYPE string, v_error_msg TYPE string. START-OF-SELECTION. * Create object for Encryption CREATE OBJECT o_encryptor. * *&---------------------------------------------------------------------* * Encryption - String to String *&---------------------------------------------------------------------* WRITE / ‘Encryption - String to String‘. TRY. CALL METHOD o_encryptor->encrypt_string2string EXPORTING the_string = v_ac_string RECEIVING result = v_en_string. CATCH cx_encrypt_error INTO o_cx_encrypt_error. CALL METHOD o_cx_encrypt_error->if_message~get_text RECEIVING result = v_error_msg. MESSAGE v_error_msg TYPE ‘E‘. ENDTRY. WRITE:/ ‘Actual String: ‘, v_ac_string. WRITE:/ ‘Encrypted String: ‘, v_en_string. SKIP. * *&---------------------------------------------------------------------* * Decryption - String to String *&---------------------------------------------------------------------* WRITE / ‘Decryption - String to String‘. TRY. CALL METHOD o_encryptor->decrypt_string2string EXPORTING the_string = v_en_string RECEIVING result = v_de_string. CATCH cx_encrypt_error INTO o_cx_encrypt_error. CALL METHOD o_cx_encrypt_error->if_message~get_text RECEIVING result = v_error_msg. MESSAGE v_error_msg TYPE ‘E‘. ENDTRY. WRITE:/ ‘Encrypted String: ‘, v_en_string. WRITE:/ ‘Decrypted String: ‘, v_de_string. SKIP.
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。