Hi,
I'm currently using PB2017R3 and attempting to utilize the new CrypterObject and CoderObject functionality.
I have a text file that contains encoded / encrypted information. I wish to open the file, read the file contents and decode/decrypt various data elements. I'm able to successfully open and read the contents of the file. For some data elements within the file, I need to decode and/or decrypt the current values. After performing a Base64Decode on a specific value (results in a Blob), I eventually end up with a value that appears to be a different character set than expected (extended ASCII?).
I currently do the following:
Integer li_File_Return
Long ll_File_Read_Return
String ls_Raw_IV_Value, ls_IV_Value
Blob lblb_Decoded_IV_Value
CoderObject lcode_CoderObject
lcode_CoderObject = CREATE CoderObject
li_File_Return = FileOpen(as_in_file, TextMode!, Read!, Shared!, Append!, EncodingANSI!)
ll_File_Read_Return = FileReadEx(li_File_Return, ls_In_File_Contents)
//The following variable contains a base64 encoded value
ls_Raw_IV_Value = "4efJzlmwEH73IEP/ljoKlA=="
lblb_Decoded_IV_Value = lcode_CoderObject.Base64Decode(ls_Raw_IV_Value)
ls_IV_Value = String(lblb_Decoded_IV_Value, EncodingANSI!)
//The ls_IV_Value is now populated with: áçÉÎY°~÷ Cÿ–:”
Looking to see how to get the resulting decode value be regular text. I had expected to see a 16-digit alphanumeric value representing an initialization vector that will later be used for AES/CBC decryption. Not sure what I'm doing wrong.
Thanks in advance for any guidance / suggestions.
Jason Schultz
Thank you for the suggestions. I agree that the value that I am attempting to Base64Decode() doesn't appear to be a true Base64 value. I also attempted to read into a blob and convert back to string utilizing all the different encoding types and all resulted in jibberish. Currently unsure how the value read from the source file was derived. We're currently attempting to replace existing encryption functionality that utilizes external .dlls and replace with native PB functionality. Unfortunately, the latest documentation that I have is still older and doesn't appear to align with the current functionality (since the older ingested file doesn't appear to contain the expected Base64 encoded value). I was using a source file (generated from the previous encryption .dlls) as a test case. Still a work in progress, but I appreciate the information / examples provided. It serves as a good resource. Will keep you all posted.
Maybe the problem is that the file for FileOpen() is not AnsiEncoded! Could be a text file in for example UTF8!