1.Github下载工具类https://github.com/Sumu-Ning/AES,利用abapGit上传至SAP系统
2.AES加密需要四个参数 ①密钥②加密模式③字节填充模式④偏移量
3.将明文转XSTRING,密钥BASE64解码,调用zcl_aes_utility=>encrypt_xstring方法
METHOD aes_encrypt.
DATA:lv_content_xstr TYPE xstring,
lv_key_xstr TYPE xstring,
lv_response_xstr TYPE xstring.
"#明文
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = iv_content
IMPORTING
buffer = lv_content_xstr
EXCEPTIONS
failed = 1.
"#密钥
CALL FUNCTION 'SCMS_BASE64_DECODE_STR'
EXPORTING
input = gc_aes_key
IMPORTING
output = lv_key_xstr
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
zcl_aes_utility=>encrypt_xstring(
EXPORTING
i_key = lv_key_xstr
i_data = lv_content_xstr
i_encryption_mode = zcl_aes_utility=>mc_encryption_mode_ecb
i_padding_standard = zcl_byte_padding_utility=>mc_padding_standard_pkcs_7 "字节填充模式
IMPORTING
e_data = lv_response_xstr ).
CALL FUNCTION 'ZBC_CONVERT_XSTRING_TO_BYTE'
EXPORTING
iv_xstring = lv_response_xstr
IMPORTING
ev_byte_string = ev_response.
ENDMETHOD.
文章介绍了如何使用Github的AES工具类下载并加密数据,包括明文转换为XSTRING、Base64解密密钥,最后通过zcl_aes_utility进行ECB模式加密的过程。
711

被折叠的 条评论
为什么被折叠?



