Advertisement
Python253

decode_0bin

Mar 5th, 2024
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Filename: decode_0bin.py
  4. # Author: Jeoi Reqi
  5.  
  6. """
  7. This Python script decodes the contents of '0.bin' file and saves the result as plain text in a txt file.
  8.  
  9. Requirements:
  10. - Python 3
  11. """
  12.  
  13. import os
  14.  
  15. def decode_binary_file(input_file, output_file):
  16.     with open(input_file, 'rb') as binary_file:
  17.         # Read binary data
  18.         binary_data = binary_file.read()
  19.  
  20.         # Decode binary data into ASCII plaintext
  21.         decoded_text = binary_data.decode('utf-8')
  22.  
  23.         # Write the decoded text to the output file
  24.         with open(output_file, 'w') as plaintext_file:
  25.             plaintext_file.write(decoded_text)
  26.  
  27. if __name__ == "__main__":
  28.     # Specify the input and output file names
  29.     input_file_0 = '0.bin'
  30.     output_file_0 = 'decoded_0.txt'
  31.  
  32.     # Decode 0.bin
  33.     decode_binary_file(input_file_0, output_file_0)
  34.     print(f'{input_file_0} decoded and saved to {output_file_0}')
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement