You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm attempting to create a script that is inspired by your post (and this project). My ultimate objective is to extract, modify, and inject the BICS_VIEW_HEADER in an Excel file. I'd like to use Python, and I've managed to do every step except I can't seem to replicate the DecompressString function correctly. Are you able to help out?
If I understand correctly, the operation that decompresses the Base64 string is Convert.FromBase64String(compressedText), and then to return it as UTF8, you use Encoding.UTF8.GetString. The other operations within the function are to write the values to a buffer stream of the right size (not required in python). Is this correct? I assume I am missing something, because the equivalent in Python is returning me gibrish... I've had to ignore errors to get it working altogether for the content of the BICS_VIEW_HEADER tag.
I had the same issue when I tried to extract the BICS_VIEW_HEADER using Python and came across this repository. The solution is that you have to ignore the first four bytes of the BICS_VIEW_HEADER - it seems this is done in the DecompressString function using the Write method of the MemoryStream:
Using Python the decompression of the string is quite easy (assuming bics_view_header is the text between the BICS_VIEW_HEADER tags of the xml; you do not have to encode it using ascii characters first, because b64decode can also work with strings):
I'm attempting to create a script that is inspired by your post (and this project). My ultimate objective is to extract, modify, and inject the BICS_VIEW_HEADER in an Excel file. I'd like to use Python, and I've managed to do every step except I can't seem to replicate the DecompressString function correctly. Are you able to help out?
If I understand correctly, the operation that decompresses the Base64 string is Convert.FromBase64String(compressedText), and then to return it as UTF8, you use Encoding.UTF8.GetString. The other operations within the function are to write the values to a buffer stream of the right size (not required in python). Is this correct? I assume I am missing something, because the equivalent in Python is returning me gibrish... I've had to ignore errors to get it working altogether for the content of the BICS_VIEW_HEADER tag.
Here's the function in Python:
def string_decoder(string):
base64_bytes = string.encode('ascii')
message_bytes = base64.b64decode(base64_bytes)
message = message_bytes.decode('utf-8', errors='ignore')
return message
The text was updated successfully, but these errors were encountered: