Created
October 2, 2016 00:54
-
-
Save TheCynosure/0dab1daf79eed91ef71a220b6f243e74 to your computer and use it in GitHub Desktop.
A tiny python script to write hex values to a file directly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
2 import binascii | |
3 | |
4 if len(sys.argv) < 3: | |
5 print("Proper Usage is: hexWriter.py [inputFile] [outputFile]") | |
6 print("The file must have hex digits seperated by spaces.") | |
7 else: | |
8 content = open(sys.argv[1]) | |
9 content = content.read()[:-1].split(" ") #Slice off that pesky extra \n | |
10 output = binascii.a2b_hex(''.join(content)) | |
11 out = open(sys.argv[2], "w+") | |
12 out.write(output) | |
# Example File : 47 49 46 38 39 61 0A 00 0A 00 91 00 00 FF FF FF FF 00 00 00 00 FF 00 00 00 21 F9 04 00 00 00 00 00 2C 00 00 00 00 0A 00 0A 00 00 02 16 8C 2D 99 87 2A 1C DC 33 A0 02 75 EC 95 FA A8 DE 60 8C 04 91 4C 01 00 3B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment