To read back the files and decode the ASCII85 (a85) encoded parts into a single string, you need to perform the reverse process of what you did to encode them. Here’s how you can do it:
# Function to decode ASCII85 encoded string
def decode_ascii85(encoded_string):
return base64.a85decode(encoded_string.encode('utf-8')).decode('utf-8')
# Read each segment from files and decode them
for filename in filenames:
with open(filename, 'r') as file:
encoded_segment = file.read()
decoded_segment = decode_ascii85(encoded_segment)
decoded_parts.append(decoded_segment)
# Join the decoded parts into a single string
decoded_code = ''.join(decoded_parts)
# Clean up the decoded code if necessary (remove extra spaces, etc.)
decoded_code = decoded_code.strip()
# Now, `decoded_code` contains the complete decoded string
This script reads each binary file, decodes its content using the decode_ascii85 function, and then appends the decoded segment to a list. Finally, it joins all the decoded segments into a single string.