Advertisement
iqhtyar2k

Bin2Text

Jan 21st, 2024
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. import binascii
  2.  
  3. def convert_bin_to_text(bin_data):
  4.   return binascii.hexlify(bin_data).decode("utf-8").replace(" ", "")
  5.  
  6. def convert_bin_to_file(bin_data, filename):
  7.   with open(filename, "w") as f:
  8.     f.write(convert_bin_to_text(bin_data))
  9.  
  10. if __name__ == "__main__":
  11.   # Buka file bin
  12.   with open("code.bin", "rb") as f:
  13.     bin_data = f.read()
  14.  
  15.   # Konversi file bin ke format teks
  16.   text = convert_bin_to_text(bin_data)
  17.  
  18.   # Konversi file bin ke file txt
  19.   convert_bin_to_file(text, "code.txt")
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement