分类: Web开发
2015-06-04 14:51:45
SCMS_BASE64_ENCODE
HTTP_BASE64_ENCODE
SSFC_BASE64_CODE
FUNCTION zfm_test_url8.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" REFERENCE(IV_CHAR) TYPE CHAR100
*" EXPORTING
*" REFERENCE(EV_MD5) TYPE CHAR32
*"----------------------------------------------------------------------
CLEAR ev_md5 .
CALL FUNCTION 'MD5_CALCULATE_HASH_FOR_CHAR'
EXPORTING
data = iv_char
IMPORTING
hash = ev_md5
EXCEPTIONS
no_data = 1
internal_error = 2
OTHERS = 3.
DATA: lv_input TYPE string,
lv_unescaped TYPE string,
lv_escaped TYPE string,
lv_return_code TYPE i.
***********Example for URL encoding
CLEAR:lv_input,lv_unescaped,lv_escaped,lv_return_code .
lv_input = ''.
CALL METHOD cl_http_utility=>escape_url
EXPORTING
unescaped = lv_input
RECEIVING
escaped = lv_escaped.
CALL METHOD cl_http_utility=>get_last_error
RECEIVING
rc = lv_return_code.
***********Example for URL decoding
CALL METHOD cl_http_utility=>unescape_url
EXPORTING
escaped = lv_escaped
RECEIVING
unescaped = lv_unescaped.
CALL METHOD cl_http_utility=>get_last_error
RECEIVING
rc = lv_return_code.
ENDFUNCTION.
AES 加密
CL_SEC_SXML_WRITER
DATA:
lv_ac_string TYPE string VALUE 'Welcome to ABAP',
lv_ac_xtring TYPE xstring,
lv_en_string TYPE string,
lv_en_xtring TYPE xstring,
lv_de_string TYPE string,
lv_de_xtring TYPE xstring.
PARAMETERS: p_string TYPE string DEFAULT 'Welcome to ABAP'.
START-OF-SELECTION.
CLEAR: lv_ac_string,lv_en_string,lv_de_string .
CLEAR: lv_ac_xtring,lv_en_xtring,lv_de_xtring .
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = p_string
IMPORTING
buffer = lv_ac_xtring
EXCEPTIONS
failed = 1
OTHERS = 2.
CALL FUNCTION 'SSFC_BASE64_ENCODE'
EXPORTING
bindata = lv_ac_xtring
IMPORTING
b64data = lv_en_string
EXCEPTIONS
ssf_krn_error = 1
ssf_krn_noop = 2
ssf_krn_nomemory = 3
ssf_krn_opinv = 4
ssf_krn_input_data_error = 5
ssf_krn_invalid_par = 6
ssf_krn_invalid_parlen = 7
OTHERS = 8.
WRITE:/ 'Actual String: ', p_string.
WRITE:/ 'Encrypted String: ', lv_en_string.
SKIP.
CALL FUNCTION 'SSFC_BASE64_DECODE'
EXPORTING
b64data = lv_en_string
IMPORTING
bindata = lv_de_xtring
EXCEPTIONS
ssf_krn_error = 1
ssf_krn_noop = 2
ssf_krn_nomemory = 3
ssf_krn_opinv = 4
ssf_krn_input_data_error = 5
ssf_krn_invalid_par = 6
ssf_krn_invalid_parlen = 7
OTHERS = 8.
CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
EXPORTING
im_xstring = lv_de_xtring
IMPORTING
ex_string = lv_de_string.
WRITE:/ 'Encrypted String: ', lv_en_string.
WRITE:/ 'Decrypted String: ', lv_de_string.