1. Richard Donagrandi
  2. PowerBuilder
  3. Wednesday, 9 September 2020 21:04 PM UTC

I am using the CrypterObject to encrypt some data. I can encrypt and decrypt within the same .exe just fine. I built a second program to encrypt the same (unencrypted) data -- but the two programs are encrypting the same data completely differently even though they use the same code to encrypt:

lblb_data = Blob(as_data, EncodingANSI!)
lblb_key = Blob(as_key, EncodingANSI!)
lblb_iv = Blob(as_iv, EncodingANSI!)


lblb_encrypt = inv_CO.SymmetricEncrypt(AES!, lblb_data, lblb_key, OperationModeCBC!, lblb_iv, PKCSPadding!)

ls_return = inv_code.HexEncode(lblb_encrypt)

RETURN ls_return

-------------

The decrypt is also identical:

lblb_data = inv_code.HexDecode(as_data)
lblb_key = Blob(as_key, EncodingANSI!)
lblb_iv = Blob(as_iv, EncodingANSI!)


// Decrypt data using AES
lblb_decrypt = inv_CO.SymmetricDecrypt(AES!, lblb_data, lblb_key, OperationModeCBC!, lblb_iv, PKCSPadding!)

ls_return = String(lblb_decrypt, EncodingANSI!)

RETURN ls_return

-------------------

The as_data, as_key, and as_iv values are identical in both programs, but I'm getting different results. The goal is that both programs would encrypt and decrypt the same information without error.

As it is, program 2 can't decrypt program 1's encrypted data even though they are sharing the same key and initialization vector.

I'm not seeing much in documentation that would tell me why the two programs can't share encrypted data....

What am I missing?

Richard Donagrandi Accepted Answer Pending Moderation
  1. Wednesday, 9 September 2020 22:00 PM UTC
  2. PowerBuilder
  3. # 1

nevermind... I forgot I commented out some code that determined the key for testing. So the issue was that the keys were actually different... 

All's well..

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.
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.