- Richard Donagrandi
- PowerBuilder
- Wednesday, 9 September 2020 09: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?
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.