Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Password encryption and decryption

Former Member
0 Kudos

Hi All,

I am designing a new transaction for which the initial screen is log on page. In this screen user enters his user id and password and starts his normal process. Here i want to store the user ids and passwords in a ztable and when user tries to access this transaction first i want verify his credentials. So here i want to encrypt the passwords and will store in z table and for verification i want to decrypt it to check.

Can any one please tell me is there any Fms to achieve the above requirement..

Thanks,CS Reddy

1 ACCEPTED SOLUTION

Former Member

Try these functions:

FC_SET_ENCRYPT_SETID

FIEB_PASSWORD_ENCRYPT

G_SET_ENCRYPT_SETID

K_ENCRYPT_RESOURCE

OFX_ALS_PASSWORD_ENCRYPT

OS390_ENCRYPT

SSFH_F4_ENCRALG

Regards,

Mon Magllanes

6 REPLIES 6

Former Member

Try these functions:

FC_SET_ENCRYPT_SETID

FIEB_PASSWORD_ENCRYPT

G_SET_ENCRYPT_SETID

K_ENCRYPT_RESOURCE

OFX_ALS_PASSWORD_ENCRYPT

OS390_ENCRYPT

SSFH_F4_ENCRALG

Regards,

Mon Magllanes

0 Kudos

I had a similar requirement, I have used this FM this resolved my issue.


  IF NOT cnt > 3.
          CLEAR: pswrd,password.
          pswrd  = zoperator-paswrd.

          CALL FUNCTION 'DB_CRYPTO_PASSWORD'
            EXPORTING
              clear_text_password          = pswrd
            IMPORTING
              encoded_password             = password
            EXCEPTIONS
              crypt_output_buffer_to_small = 1
              crypt_internal_error         = 2
              crypt_truncation_error       = 3
              crypt_conversion_error       = 4
              internal_error               = 5
              OTHERS                       = 6.
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.

 LOOP AT it_opt.
            IF it_opt-paswrd  CO password.
*              CALL SCREEN 2000.
              CALL SCREEN 4000.


            ELSE.
              CLEAR: zwb_operator-opname,zwb_operator-paswrd,password,pswrd.
              MESSAGE e000(zwb) WITH 'Please enter the Valid Password'.

              .
              LEAVE TO SCREEN 1000.
              cnt =  cnt + 1.
              IF cnt > 3.
                LEAVE TO SCREEN 0.
              ENDIF.


Also use same data element which they have used in this FM.

awin_prabhu
Active Contributor
0 Kudos

Hi friend,

Use below FM's

Encryption:

CALL FUNCTION 'FIEB_PASSWORD_ENCRYPT'

EXPORTING

IM_DECRYPTED_PASSWORD = pwd1

IMPORTING

EX_ENCRYPTED_PASSWORD = pwd2.

Decryption:

CALL FUNCTION 'FIEB_PASSWORD_DECRYPT'

EXPORTING

IM_ENCRYPTED_PASSWORD = pwd2

IMPORTING

EX_DECRYPTED_PASSWORD = pwd3

Might help u

Edited by: Sap Fan on Feb 20, 2009 9:00 AM

0 Kudos

Hi ,

I have used 'FIEB_PASSWORD_ENCRYPT' and 'FIEB_PASSWORD_DECRYPT' function modules for encryption and decryption. But am not getting the decrypted Password from decrypt FM. It is showing blank value..

Can any one please suggest some other FM?

0 Kudos

Hi, I've also tried function group FIEB_PASSWORD, which was not working like I expected. I checked group and find out possible problem. At least with version from few systems I checked. I have read it can work on some older releases. I found out that encrypt/decrypt uses form from include "LFIEB_PASSWORDF01" > "character_search". This form should return position of character from string.

Original source code:


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

Problem is variable "l_length" in do enddo loop. It's not set to any value (commented). It's always "0".

l_length = 0 (always)

So it won't ever return correct position of character.

ch_pos = -1 (always)

So there's need to correct this. You can copy whole group and make "Z/Y" one. I used implicit enhancement. We cannot simply un-comment line. So we need to correct code and exit processing of standard code with adding this code to enhancement at begin of form:


ch_pos = -1.
find im_character in im_string match offset ch_pos.
exit. " => don't continue processing of standard code

Corrected source code:


FORM character_search USING    im_string
                               im_character
                      CHANGING ch_pos             type i.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1 ) Form CHARACTER_SEARCH
*$*$-Start: (1 )--------------------------------------------------------------------------------$*$*
ENHANCEMENT 1  ZFBZI_FIEB_PASSWORD.    "active version
*
    ch_pos = -1.
    find im_character in im_string match offset ch_pos.

    exit. " => don't continue processing of standard code

ENDENHANCEMENT.
*$*$-End:   (1 )--------------------------------------------------------------------------------$*$*

  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

It's not universal solution, as far as SAP can decide to correct this but still we'll use our code. So we can place enhancement in the end of form and add condition for our code:


check ( ch_pos = -1 ). " <= run only if character is not found
find im_character in im_string match offset ch_pos.

Decision is up to you. Both solutions will work OK.

PS: Just remember, that this FM(s) are not very secure as you can decrypt passwords simply by finding them in table "FIEB_PASSWORD" and using FM "FIEB_PASSWORD_GET" to get all passwords by ID or using SE37/debug, .... And while testing don't forget to set checkbox "Uppercase/Lowercase" .

Former Member
0 Kudos

Hi,

Search the function group 'FIEB_PASSWORD'.

There u can find various function modules to play around.

for more details check this link

[http://sap.ittoolbox.com/groups/technical-functional/sap-dev/password-encryption-741992]

hope the content helps u..

Thank you