1. Anders Ångström
  2. PowerBuilder
  3. Thursday, 14 February 2019 13:35 PM UTC

When using the the method SymmetricEncrypt, the blob that is returned is in chinese.

I have put the following script in the clicked event and show the result in the textobject st_1:

Blob lblb_data
Blob lblb_key
Blob lblb_iv
Blob lblb_encrypt

lblb_data = Blob("text", EncodingUTF16LE! )
lblb_key = Blob("Test Key12345678", EncodingUTF16LE! )
lblb_iv = Blob("Test IV 12345678", EncodingUTF16LE! )

CrypterObject lnv_CrypterObject
lnv_CrypterObject = Create CrypterObject


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

st_1.text = string(lblb_encrypt)

This screenshoot is what it look like:

What am I doing wrong?

Accepted Answer
Ken Guo @Appeon Accepted Answer Pending Moderation
  1. Saturday, 16 February 2019 07:45 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi Anders,

It indeed returns Chinese when directly getting the encrypted Blob data, which is normal, It’s because the encrypted blob data itself is not human readable. However it does not affect PB to execute the decryption functions. If you run the below script, you’ll find it returns the original text:

lblb_encrypt = lnv_CrypterObject.Symmetricdecrypt( AES!, lblb_encrypt,lblb_key)

messagebox('', string(lblb_encrypt))

 

It did not return Chinese in Bruce’s YouTube demo, probably it is because he got the encrypted blob data converted to base64, for example: lco_CoderObject.base64encode(lb_data)

 

Regards,

Ken

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Friday, 15 February 2019 14:29 PM UTC
  2. PowerBuilder
  3. # 1

The 'Chinese' is likely due to a blob with ANSI characters being converted to a string without first being converted to Unicode.

There is a possibility that your test string is too short. Encryption algorithms sometimes have issues with very short values.

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 14 February 2019 13:45 PM UTC
  2. PowerBuilder
  3. # 2

The help file example uses EncodingANSI! while you are using EncodingUTF16LE!. I would try it without any encoding and with ANSI like the help file to see which one works best.

Comment
  1. Anders Ångström
  2. Friday, 15 February 2019 07:36 AM UTC
Hi Roland!

Thank you for the answer! I tried with using EncodingANSI and without any encoding, but the result still comes out in chinese!
  1. Helpful
There are no comments made yet.
Brad Mettee Accepted Answer Pending Moderation
  1. Thursday, 14 February 2019 13:42 PM UTC
  2. PowerBuilder
  3. # 3

You aren't doing anything wrong. The resulting blob is encrypted, and may have binary data in it. This data may not be human readable. As long as you can send the blob back through decrypt and get the original string, everything is working ok.

Why do you need to display the encrypted string? Or is that only so you can see that the encryption is working?

Comment
  1. Anders Ångström
  2. Friday, 15 February 2019 07:44 AM UTC
Hi Brad!

Yes, I only display the rsult to see if it is working!

Something is wrong! I have watched Appeon Community Webinar's Youtube video "PB 2017 R3 New Features: Encryption & Related" by Bruce Armstrong and the result that is shown there is not in chinese, but in a readeable format.

Even when I decrypt the result I get it comes out in chinese!
  1. Helpful
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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.