on 03-08-2008 9:00 AM
Hi, experts,
I need to encrypt a string and decrypt the encrypted string .
Action:
1. create three input fields(password_input, encrypted_input, decrypted_input) and two button (encrypted_button and decrypted_button) in the view of the WDA.
2. run the application.
3. When type the password in the password_input, clicking the encrypted_button, the encrypted data is put in the encrypted_input.
4. When click the decrypted_button, the encrypted data is decrypted and put it to the decrypted_input.
I don't know how to complete the 3 and 4 step. I need some code or example for coding the encrypting and decrypting.
Thanks a lot.
Best regards,
Tao
Hi, Wang,
I don´t know in which version you are, but you can check if there is the class (SE24) CL_HARD_WIRED_ENCRYPTOR, and try it.
Hope this helps!
Andre
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Andre,
Thanks a lot for your help in advance.
The version of my R3 system is that basis is 14, and abap is 14.
I can find the class CL_HARD_WIRED_ENCRYPTOR, and find the CLASS_CONSTRUCTOR method to create a object that type is CL_HARD_WIRED_ENCRYPTOR. I modify my code of the method ONACTIONSETENCRYPTED. The following is my code:
method ONACTIONSETENCRYPTED .
DATA lo_nd_node TYPE REF TO if_wd_context_node.
DATA lo_el_node TYPE REF TO if_wd_context_element.
DATA if_encrypt TYPE REF TO CL_HARD_WIRED_ENCRYPTOR.
DATA ls_node TYPE wd_this->element_node.
DATA lv_password LIKE ls_node-password.
DATA lv_encrypted_password LIKE ls_node-encrypted_password.
DATA lv_decrypted_password LIKE ls_node-decrypted_password.
navigate from <CONTEXT> to <NODE> via lead selection
lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).
get element via lead selection
lo_el_node = lo_nd_node->get_element( ).
get single attribute
lo_el_node->get_attribute(
EXPORTING
name = `PASSWORD`
IMPORTING
value = lv_password ).
create a CL_HARD_WIRED_ENCRYPTOR
if_encrypt = CL_HARD_WIRED_ENCRYPTOR=>CLASS_CONSTRUCTOR( ).
ENCRYPTOR the string
lv_encrypted_password = if_encrypt=>ENCRYPT_STRING2STRING( THE_STRING = lv_password ).
DECRYPTOR the string
lv_decrypted_password = if_encrypt=>DECRYPT_STRING2STRING( THE_STRING = lv_encrypted_password ).
endmethod.
But when I compiled my code, the system occured a error: You cannot call the special method "CLASS_CONSTRUCTOR(" directly.
I don't know how to solve the problem, and how to create the object of CL_HARD_WIRED_ENCRYPTOR type for encrypting and decrypting. I need some code or example for coding the CL_HARD_WIRED_ENCRYPTOR class.
Do you give me some hints? Thanks a lot.
Thanks a billion.
Best regards,
Tao
Hi,
Try this way, it will solve your problem....you can not call constructor of the class directly....
*this code is under the encrypt button
DATA if_encrypt TYPE REF TO cl_hard_wired_encryptor.
CREATE OBJECT if_encrypt.
ENCRYPTOR the string
TRY.
CALL METHOD if_encrypt->encrypt_string2string
EXPORTING
the_string = lv_string_value <-this is a string coming from user-i mean user input this value from the screen
receiving
RESULT = lv_encypt_value <----this one i declared as string as well...
.
CATCH cx_encrypt_error .
ENDTRY.
*for decryption--- put this code under your decrypt button
*since they are two different action methods that is why i needed to create the instance again.
DATA if_encrypt TYPE REF TO cl_hard_wired_encryptor.
CREATE OBJECT if_encrypt.
TRY.
CALL METHOD if_encrypt->decrypt_string2string
EXPORTING
the_string = lv_encypt_value <---declared as string, as above
receiving
RESULT = lv_decrypt_value <---declared as string as well
.
CATCH cx_encrypt_error .
ENDTRY.
thanks
AS.
hi tao!
How to troubleshoot the error ?????
"You cannot call the special method "CLASS_CONSTRUCTOR(" directly. "
reference:
eh tried but nothing.... and I have the same code that you.
Best regards,
RHD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.