码迷,mamicode.com
首页 > 其他好文 > 详细

ABAP 加密解密程序

时间:2014-06-02 11:53:34      阅读:339      评论:0      收藏:0      [点我收藏+]

标签:c   style   class   blog   code   java   

用于对字符串的加密和解密:
 

bubuko.com,布布扣
DATA: o_encryptor        TYPE REF TO cl_hard_wired_encryptor,
     o_cx_encrypt_error TYPE REF TO cx_encrypt_error.
DATA: v_ac_string  TYPE string VALUE RICK,
      v_ac_xstring TYPE xstring,
      v_en_string  TYPE string,
      v_en_xstring TYPE xstring,
      v_de_string  TYPE string,
      v_de_xstring TYPE string,
      v_error_msg  TYPE string.

START-OF-SELECTION.
* Create object for Encryption
  CREATE OBJECT o_encryptor.
* *&---------------------------------------------------------------------*
* Encryption - String to String
*&---------------------------------------------------------------------*
  WRITE / Encryption - String to String.
  TRY.
      CALL METHOD o_encryptor->encrypt_string2string
        EXPORTING
          the_string = v_ac_string
        RECEIVING
          result     = v_en_string.
    CATCH cx_encrypt_error INTO o_cx_encrypt_error.
      CALL METHOD o_cx_encrypt_error->if_message~get_text
        RECEIVING
          result = v_error_msg.
      MESSAGE v_error_msg TYPE E.
  ENDTRY.
  WRITE:/ Actual String: , v_ac_string.
  WRITE:/ Encrypted String: , v_en_string.
  SKIP.
*   *&---------------------------------------------------------------------*
* Decryption - String to String
*&---------------------------------------------------------------------*
  WRITE / Decryption - String to String.
  TRY.
      CALL METHOD o_encryptor->decrypt_string2string
        EXPORTING
          the_string = v_en_string
        RECEIVING
          result     = v_de_string.
    CATCH cx_encrypt_error INTO o_cx_encrypt_error.
      CALL METHOD o_cx_encrypt_error->if_message~get_text
        RECEIVING
          result = v_error_msg.
      MESSAGE v_error_msg TYPE E.
  ENDTRY.
  WRITE:/ Encrypted String: , v_en_string.
  WRITE:/ Decrypted String: , v_de_string.
  SKIP.
bubuko.com,布布扣

bubuko.com,布布扣

ABAP 加密解密程序,布布扣,bubuko.com

ABAP 加密解密程序

标签:c   style   class   blog   code   java   

原文地址:http://www.cnblogs.com/ruingy/p/Rick.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!