概述
*&---------------------------------------------------------------------*
*& Report ZTEST_BASE64
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTEST_BASE64.
DATA: INSTR TYPE STRING,
XSTR TYPE XSTRING,
ENCODE_STR TYPE STRING,
CHARSET TYPE STRING,
MIMETYPE(128) TYPE C,
CODEPAGE(4) TYPE N,
ENCODING(20) TYPE C,
CONVIN TYPE REF TO CL_ABAP_CONV_IN_CE.
*INSTR = 'Material : 8630052669852'.
INSTR = '我的名字叫做Michael!'.
WRITE : / '------Base64之前------:',INSTR.
CONCATENATE '"text/html; charset=' CHARSET '"' INTO MIMETYPE.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = INSTR
MIMETYPE = MIMETYPE
IMPORTING
BUFFER = XSTR
EXCEPTIONS
FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ENDIF.
CALL FUNCTION 'SCMS_BASE64_ENCODE_STR'
EXPORTING
INPUT = XSTR
IMPORTING
OUTPUT = ENCODE_STR.
WRITE : / '------Base64加密------:',ENCODE_STR.
CALL FUNCTION 'SCMS_BASE64_DECODE_STR'
EXPORTING
INPUT = ENCODE_STR
* UNESCAPE = 'X'
IMPORTING
OUTPUT = XSTR
EXCEPTIONS
FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ENDIF.
CHARSET = 'UTF-8'."支持中文
CALL FUNCTION 'SCP_CODEPAGE_BY_EXTERNAL_NAME'
EXPORTING
EXTERNAL_NAME = CHARSET
IMPORTING
SAP_CODEPAGE = CODEPAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC = 0.
ENCODING = CODEPAGE.
ENDIF.
CONVIN = CL_ABAP_CONV_IN_CE=>CREATE( ENCODING = ENCODING INPUT = XSTR )."创建解码对象
CALL METHOD CONVIN->READ( IMPORTING DATA = INSTR ).
WRITE : / '------Base64解密------:',INSTR.
最后
以上就是魁梧冰淇淋为你收集整理的【Demo】ABAP Base64加解密测试的全部内容,希望文章能够帮你解决【Demo】ABAP Base64加解密测试所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复