본문 바로가기

ERP_Work/ABAP

FIEB_PASSWORD

FUNCTION FIEB_PASSWORD_DECRYPT.

*"----------------------------------------------------------------------

*"*"Lokale Schnittstelle:

*" IMPORTING

*" VALUE(IM_ENCRYPTED_PASSWORD) TYPE FIEB_ENCRYPTED_PASSWD

*" EXPORTING

*" VALUE(EX_DECRYPTED_PASSWORD) TYPE FIEB_DECRYPTED_PASSWD

*"----------------------------------------------------------------------

   

* decrypt the encrypted password

perform decrypt_password

using

im_encrypted_password

changing

ex_decrypted_password.

   

ENDFUNCTION.

FUNCTION FIEB_PASSWORD_ENCRYPT.

*"----------------------------------------------------------------------

*"*"Lokale Schnittstelle:

*" IMPORTING

*" VALUE(IM_DECRYPTED_PASSWORD) TYPE FIEB_DECRYPTED_PASSWD

*" EXPORTING

*" VALUE(EX_ENCRYPTED_PASSWORD) TYPE FIEB_ENCRYPTED_PASSWD

*"----------------------------------------------------------------------

   

* encrypt the decrypted password

perform encrypt_password

using

im_decrypted_password

changing

ex_encrypted_password.

   

ENDFUNCTION.

   

   

   

   

LFIEB_PASSWORDF01

   

*----------------------------------------------------------------------*

***INCLUDE LFIEB_PASSWORDF01 .

*----------------------------------------------------------------------*

*&---------------------------------------------------------------------*

*& Form CHECK_IF_CARACTERS_ARE_VALID

*&---------------------------------------------------------------------*

* Checks if all characters of the imported decrypted password are

* valid password-characters.

*----------------------------------------------------------------------*

* -->P_DECRYPTED_PASSWORD text

* <--CH_BOOLEAN 'X' if all characters are valid

*----------------------------------------------------------------------*

FORM CHECK_IF_CARACTERS_ARE_VALID

USING

P_DECRYPTED_PASSWORD

CHANGING

ch_BOOLEAN.

   

if p_decrypted_password CO co_password_characters.

ch_boolean = 'X'.

else.

ch_boolean = ' '.

endif.

   

ENDFORM. " CHECK_IF_ALL_CARACTERS_ARE_VAL

   

*&---------------------------------------------------------------------*

*& Form ENCRYPT_PASSWORD

*&---------------------------------------------------------------------*

* Encrypt the imported (decrypted) password.

*----------------------------------------------------------------------*

* -->IM_DECRYPTED_PASSWORD text

* <--ch_ENCRYPTED_PASSWORD text

*----------------------------------------------------------------------*

FORM ENCRYPT_PASSWORD USING IM_DECRYPTED_PASSWORD

CHANGING CH_ENCRYPTED_PASSWORD.

   

* We use a simple 'Vigenere-Chiffre' (but with a long key) and

* add a accumulated index to it.

* By now the encrypted and the decrypted password have the same

* length (32)

   

data:

l_index type i,

l_number type i,

l_key_val type i,

l_passwd_val type i,

l_accumulate type i.

   

clear ch_encrypted_password.

   

l_index = 0.

l_accumulate = 0.

* encrypt the maximal length of the decrypted password, not just the

* filled part of the decrypted password

do co_password_length times.

* check out the index in the key

perform character_search

using

co_password_characters

co_key+l_index(1)

changing

l_key_val.

* check out the index in the decrypted password

perform character_search

using

co_password_characters

im_decrypted_password+l_index(1)

changing

l_passwd_val.

* calculate the index of the character for the encrypted password

l_number = ( l_accumulate + l_key_val + l_passwd_val ) mod

co_number_of_characters.

ch_encrypted_password+l_index(1) =

co_password_characters+l_number(1).

l_index = l_index + 1.

* Accumulate the index of the characters in the decrypted password

l_accumulate = l_accumulate + l_passwd_val.

enddo.

   

ENDFORM. " ENCRYPT_PASSWORD

   

   

*&---------------------------------------------------------------------*

*& Form DECRYPT_PASSWORD

*&---------------------------------------------------------------------*

* Decrypt the imported (encrypted) password.

*----------------------------------------------------------------------*

* -->IM_ENCRYPTED_PASSWORD text

* <--CH_DECRYPTED_PASSWORD text

*----------------------------------------------------------------------*

FORM DECRYPT_PASSWORD USING IM_ENCRYPTED_PASSWORD

CHANGING CH_DECRYPTED_PASSWORD.

   

* We use a simple 'Vigenere-Chiffre' (but with a long key) and

* add a accumulated index to it.

* By now the encrypted and the decrypted password have the same

* length (32)

   

data:

l_index type i,

l_number type i,

l_key_val type i,

l_passwd_val type i,

l_accumulate type i.

   

clear ch_decrypted_password.

   

l_index = 0.

l_accumulate = 0.

* encrypt the maximal length of the decrypted password, not just the

* filled part of the decrypted password

do co_password_length times.

* check out the index in the key

perform character_search

using

co_password_characters

co_key+l_index(1)

changing

l_key_val.

* check out the index in the encrypted password

perform character_search

using

co_password_characters

im_encrypted_password+l_index(1)

changing

l_passwd_val.

* calculate the index of the character for the encrypted password

l_number = ( l_passwd_val - l_accumulate - l_key_val ) mod

co_number_of_characters.

ch_decrypted_password+l_index(1) =

co_password_characters+l_number(1).

l_index = l_index + 1.

* Accumulate the index of the characters in the decrypted password

l_accumulate = l_accumulate + l_number.

enddo.

   

ENDFORM. " DECRYPT_PASSWORD

   

   

*&---------------------------------------------------------------------*

*& Form character_search

*&---------------------------------------------------------------------*

* Search a character in the imported field and returns the

* position of the character. Note that '*' and other special

* characters are treated as normal characters here.

*----------------------------------------------------------------------*

* -->im_string

* -->im_character

* <--ch_pos "position of the character (-1 if not found)

*----------------------------------------------------------------------*

FORM character_search USING im_string

im_character

CHANGING ch_pos type i.

   

data:

l_index type i,

l_length type i.

   

* describe field im_string length l_length.

   

ch_pos = -1.

l_index = 0.

do l_length times.

if im_string+l_index(1) = im_character.

ch_pos = l_index.

exit.

endif.

l_index = l_index + 1.

enddo.

   

ENDFORM. " character_search

   

   

LFIEB_PASSWORDTOP

   

FUNCTION-POOL FIEB_PASSWORD. "MESSAGE-ID ..

   

constants:

* This are the characters that are allowed for the decrypted password

co_password_characters(94) type c value

' !"#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQ' &

'RSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~', "#EC NOTEXT

* number of passwrod characters

co_number_of_characters type i value 94,

* max length of the encrypted and of the decrypted password

co_password_length type i value 32,

* This is the key

co_key(32) type c value

'Wz=M?LrU&N\`E!@mBb K/n)e;SvR+Da['. "#EC NOTEXT