1. Bala Kotha
  2. PowerBuilder
  3. Monday, 14 September 2020 15:55 PM UTC

Hello All,

I am trying to pull the encrypted value from the .ini file (Configuration file) file and decrypt it using Base64Encode and Base64Decode. I successfully captured the encrypted value, but when I am trying to Decrypt it, I am not getting the expected result.

Below is the piece of logic which I have written: 

Blob   lblb_Pwd, lblb_UserID, lblb_UserID1
String ls_Base64Pwd, ls_Base64UserID, ls_app_username

lblb_UserID = Blob("gs_app.ss_app_ini", EncodingANSI!)

CoderObject lnv_CoderObject
lnv_CoderObject = Create CoderObject

ls_app_username = ProfileString(gs_app.ss_app_ini,"default","username","")
MessageBox("ls_app_username",ls_app_username)

ls_Base64UserID= lnv_CoderObject.Base64Encode(lblb_UserID)

gs_app.ss_user_name = ls_Base64UserID
MessageBox(".ini UserID",gs_app.ss_user_name)
lblb_UserID1 = lnv_CoderObject.Base64Decode(ls_Base64UserID)
messagebox("Base64Decode", string(lblb_UserID1, EncodingANSI!))

Thanks & Regards

Gopal.

Suhas Shravagi Accepted Answer Pending Moderation
  1. Monday, 21 September 2020 16:56 PM UTC
  2. PowerBuilder
  3. # 1

Maybe you can try the solution suggested in my question for encryption-decryption.

URL: https://community.appeon.com/index.php/qna/q-a/encryption-decryption-not-working

Thanks!

Comment
There are no comments made yet.
Ken Guo @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 15 September 2020 06:36 AM UTC
  2. PowerBuilder
  3. # 2

Hi Bala,

There is no encoded value saved in the ini file in your sample code so the value decoded is not as you expected.
If you want to use CoderObject to Encode and Decode, please refer to the following sample:

Blob   lblb_UserID.lblb_UserID1
String ls_Base64UserID
String ls_MyUserID
CoderObject lnv_CoderObject
lnv_CoderObject = Create CoderObject

ls_MyUserID = 'tester'

//Encode the value
lblb_UserID = Blob(ls_MyUserID, EncodingANSI!)
ls_Base64UserID= lnv_CoderObject.Base64Encode(lblb_UserID)
messagebox('Encode Value',ls_Base64UserID)

//Set the encoded value to the ini file
SetProfileString (gs_app.ss_app_ini,"default","username",ls_Base64UserID)

...

//Get the encoded value from the ini file
ls_app_username = ProfileString (gs_app.ss_app_ini,"default","username","")

//Decode the value
lblb_UserID1 = lnv_CoderObject.Base64Decode(ls_app_username)
messagebox("Base64Decode", string(lblb_UserID1, EncodingANSI!))

 

If you want to encrypt the data, please use CrypterObject as Mike suggested.


Regards,
Ken

Comment
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Monday, 14 September 2020 17:22 PM UTC
  2. PowerBuilder
  3. # 3

to be clear, you are not encrypting.  you are encoding. so that is not secure.

you may want to encrypt it as a blob, then encode the blob so you can store it as text.

for example:

lblb_data = Blob(ls_password, EncodingANSI!)

lblb_key = blob('k3yv@alue!123', encodingansi!)

lblb_encrypt = lnv_CrypterObject.SymmetricEncrypt(AES!, lblb_data, lblb_key) 
ls_64encypt = lnv_CoderObject.Base64Encode(lblb_encrypt)

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.