on 06-29-2009 5:47 AM
Dear All,
We want to store the password in encrypted formate in the table and when we are retriving the password, it should be decrypted.
Can anybody tell us how to encrypt and decrypt in Webdynpro ABAP.Is there any function for that?
Regards,
Arun
Hi Arun,
You can make use of any standard ABAP function module for encryption & decryption purpose in WDA. You dont need any special functionality from WDA for this purpose.
Regards,
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arun,
I already answer this question in the above thread....but lets explain again....
I just tested this class and it is doing what it suppose to do....only issue with the code was calling methods wrongly....
the way i did a quick check is this:
I created an input field where a user will input some string. Now I created two buttons: encrypt_btn and decrypt_btn.
for these two buttons I created two actions....which created two event handler methods for me.
My context looks like this:
ENCRYPT_NODE-----node name
-
>ENCYPT_VALUE -
attribute name type string.
DECRYPT_NODE---node name
-
>DECRYPT_VALUE ---attribute name type string.
STRING_NODE ---node name
-
>STRING_VALUE ---attribute name type string.
all these node have cardinality of 1..1.
just put this code under encrypt_btn action method: <--you need to set the node names as per your node names and attributes
DATA lo_nd_string_node TYPE REF TO if_wd_context_node.
DATA lo_el_string_node TYPE REF TO if_wd_context_element.
DATA ls_string_node TYPE wd_this->element_string_node.
DATA lv_string_value LIKE ls_string_node-string_value.
navigate from <CONTEXT> to <STRING_NODE> via lead selection
lo_nd_string_node = wd_context->get_child_node( name = wd_this->wdctx_string_node ).
get element via lead selection
lo_el_string_node = lo_nd_string_node->get_element( ).
get single attribute
lo_el_string_node->get_attribute(
EXPORTING
name = `STRING_VALUE`
IMPORTING
value = lv_string_value ).
DATA lo_nd_encrypt_node TYPE REF TO if_wd_context_node.
DATA lo_el_encrypt_node TYPE REF TO if_wd_context_element.
DATA ls_encrypt_node TYPE wd_this->element_encrypt_node.
DATA lv_encypt_value LIKE ls_encrypt_node-encypt_value.
navigate from <CONTEXT> to <ENCRYPT_NODE> via lead selection
lo_nd_encrypt_node = wd_context->get_child_node( name = wd_this->wdctx_encrypt_node ).
get element via lead selection
lo_el_encrypt_node = lo_nd_encrypt_node->get_element( ).
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
receiving
RESULT = lv_encypt_value
.
CATCH cx_encrypt_error .
ENDTRY.
get single attribute
lo_el_encrypt_node->set_attribute(
EXPORTING
name = `ENCYPT_VALUE`
IMPORTING
value = lv_encypt_value ).
Now for the decrypt_btn action method: put this following method...remember to change the node name and attribute as per your node name and attributes:
DATA lo_nd_encrypt_node TYPE REF TO if_wd_context_node.
DATA lo_el_encrypt_node TYPE REF TO if_wd_context_element.
DATA ls_encrypt_node TYPE wd_this->element_encrypt_node.
DATA lv_encypt_value LIKE ls_encrypt_node-encypt_value.
navigate from <CONTEXT> to <ENCRYPT_NODE> via lead selection
lo_nd_encrypt_node = wd_context->get_child_node( name = wd_this->wdctx_encrypt_node ).
get element via lead selection
lo_el_encrypt_node = lo_nd_encrypt_node->get_element( ).
get single attribute
lo_el_encrypt_node->get_attribute(
EXPORTING
name = `ENCYPT_VALUE`
IMPORTING
value = lv_encypt_value ).
DATA lo_nd_decrypt_node TYPE REF TO if_wd_context_node.
DATA lo_el_decrypt_node TYPE REF TO if_wd_context_element.
DATA ls_decrypt_node TYPE wd_this->element_decrypt_node.
DATA lv_decrypt_value LIKE ls_decrypt_node-decrypt_value.
navigate from <CONTEXT> to <DECRYPT_NODE> via lead selection
lo_nd_decrypt_node = wd_context->get_child_node( name = wd_this->wdctx_decrypt_node ).
get element via lead selection
lo_el_decrypt_node = lo_nd_decrypt_node->get_element( ).
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
receiving
RESULT = lv_decrypt_value
.
CATCH cx_encrypt_error .
ENDTRY.
get single attribute
lo_el_decrypt_node->set_attribute(
EXPORTING
name = `DECRYPT_VALUE`
IMPORTING
value = lv_decrypt_value ).
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.