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 encoding: string to hex and back

Former Member
0 Kudos

Hi,

I am writing an application that requires a username and password input via a WebDynpro UI.

I would like to convert this data to a hexadecimal format during passing these value to the API function

that needs them. And convert them back to string format just before calling the target API function.

This would at least prevent displaying the password in plain text in the debugger, which would be a dramatic security issue.

Any idea's?

kind regards,

Sahla

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try FM

FIEB_PASSWORD_ENCRYPT

FIEB_PASSWORD_DECRYPT

Regards,

Mohaiyuddin

16 REPLIES 16

Former Member
0 Kudos

Hi,

Try FM

FIEB_PASSWORD_ENCRYPT

FIEB_PASSWORD_DECRYPT

Regards,

Mohaiyuddin

0 Kudos

Hi,

Thanks a lot. But this FM's do not exist on my System.

Are they a part of SAP Basis?

kind regards,

Sahla

0 Kudos

Hi Sahla,

It is available in R/3, which version are you using. I don't know if they are available in < 4.7.

These are function modules provided by SAP for encrypting and decrypting passwords.

Available under Function Group

FIEB_PASSWORD

Can you check through se80, if this Function Group is available in your system ?

Regards,

Mohaiyuddin

0 Kudos

Hi,

I am developping in solution manager environment using ABAP Basis release 701.

The function group does not exist in se80.

Any suggestions?

kind regards,

Sahla

0 Kudos

No idea about SOLMAN part..

0 Kudos

Hi,

Is there any dependencies on other R/3 specific functions?

Is it possible to post me the source code?

kind regards,

Sahla

0 Kudos

Hi,

Can you try find these FMs

UIPW_DECRYPT

UIPW_ENCRYPT

They are available under Function Group UIPW. I think these are specific for UI.

Regards,

Mohaiyuddin

0 Kudos

Hi,

No, they are not available on the SMF system

regards,

Sahla

0 Kudos

Hi Sahla,

I don't know if i can copy SAP Standard code and paste it. I can give my own logic for password encryption / decryption (you can do it in thousand ways).

Regards,

Mohaiyuddin

karol_seman
Active Participant
0 Kudos

Hi Sahla,

please check the code below to see how to cast characters into hex:


data: len type i,
      off type i,
      hex1(20) type x.

data asci_str(100) type c.

field-symbols <fs> type any.

asci_str = 'abdgFÜu676!·(FPP'.

len = strlen( asci_str ).

while off lt len.
  assign asci_str+off(1) to <fs> casting type x.
  hex1+off(1) = <fs>.
  add 1 to off.
endwhile.

write: / hex1.
write: / asci_str.

0 Kudos

Hi Karol,

The encoding works fine. What's about conversion back to character?

kind regards,

Sahla

0 Kudos

Hi Sahla,

to convert it back use casting type c:



data: len type i,
      off type i,
      hex1(20) type x,
      str(20) type c.

data asci_str(100) type c.

field-symbols <fs> type any.

asci_str = 'abdgFÜu676!·(FPP'.

len = strlen( asci_str ).

while off lt len.
  assign asci_str+off(1) to <fs> casting type x.
  hex1+off(1) = <fs>.
  add 1 to off.
endwhile.

off = 0.

while off lt len.
  assign hex1+off(1) to <fs> casting type c.
  str+off(1) = <fs>.
  add 1 to off.
endwhile.


write: / asci_str.
write: / hex1.
write: / str.

Regards,

Karol

0 Kudos

Hi,

I get the message:

The length of "hex1" in bytes must be a multiple of the size of a unicode character, regardless of the size of the Unicode character.

I don't get thepoint ofthis message!??

kind regards,

Sahla

0 Kudos

Hi,

i don't get this message. I guess it is just warning and program is working. Is it correct?

The message says that length of variable hex1 must be bigger then str because hex value is represented in more bytes. Just change the declaration of hex1 length and try again. For example 40.

Karol

0 Kudos

Hi Karol,

unfortunately the error remains. It is an error and not a warning.

I changes the size to 40, 60 , 100. the error always heppens.

kind regards,

Sahla

0 Kudos

Hi,

that's very strange for me. Unfortunately it is very difficult for me to find a problem because I get no error message. Try this code where output string in without length:


data: len type i,
      off type i,
      hex1(20) type x,
      str type string.

data asci_str(10) type c.

field-symbols <fs> type any.

asci_str = 'abdgFÜu676'.

len = strlen( asci_str ).

while off lt len.
  assign asci_str+off(1) to <fs> casting type x.
  hex1+off(1) = <fs>.
  add 1 to off.
endwhile.

off = 0.

while off lt len.
  assign hex1+off(1) to <fs> casting type c.
  concatenate str <fs> into str.
  add 1 to off.
endwhile.


write: / asci_str.
write: / hex1.
write: / str.

If you have still error please copy whole text of error message here...

Regards,

Karol