Reads given file as bytes and returns them as a long string
(file_path: str)
| 8 | |
| 9 | |
| 10 | def read_file_binary(file_path: str) -> str: |
| 11 | """ |
| 12 | Reads given file as bytes and returns them as a long string |
| 13 | """ |
| 14 | result = "" |
| 15 | try: |
| 16 | with open(file_path, "rb") as binary_file: |
| 17 | data = binary_file.read() |
| 18 | for dat in data: |
| 19 | curr_byte = f"{dat:08b}" |
| 20 | result += curr_byte |
| 21 | return result |
| 22 | except OSError: |
| 23 | print("File not accessible") |
| 24 | sys.exit() |
| 25 | |
| 26 | |
| 27 | def decompress_data(data_bits: str) -> str: |