BASE64 测试&总结
Posted 10年 Java程序员,硬核人生!勇往直前,永不退缩!
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了BASE64 测试&总结相关的知识,希望对你有一定的参考价值。
DemoABAP Base64加解密测试
*&---------------------------------------------------------------------*
*& 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.
以上是关于BASE64 测试&总结的主要内容,如果未能解决你的问题,请参考以下文章