字符串的 Base64 加密和解密

base64加密:

FORM encode_base64  USING    p_business  “字符串string
                    CHANGING p_base64.

  DATA l_xstring TYPE xstring.
  CHECK p_business IS NOT INITIAL.

  CALL METHOD cl_http_utility=>encode_utf8
    EXPORTING
      unencoded = p_business
    RECEIVING
      encoded   = l_xstring.

  CALL METHOD cl_http_utility=>encode_x_base64  
    EXPORTING
      unencoded = l_xstring
    RECEIVING
      encoded   = p_base64.
ENDFORM. 

base64解密:

FORM decoding_base64 CHANGING p_business TYPE string.

  DATA l_xstring TYPE xstring.
  CALL METHOD cl_http_utility=>if_http_utility~decode_x_base64
    EXPORTING
      encoded = p_business
    RECEIVING
      decoded = l_xstring.

  CLEAR p_business.
  CALL METHOD cl_http_utility=>if_http_utility~decode_utf8
    EXPORTING
      encoded   = l_xstring
    RECEIVING
      unencoded = p_business.

ENDFORM. 

 

posted @ 2016-05-26 18:13  学习笔记NO.1  阅读(2361)  评论(0编辑  收藏  举报