Created
October 29, 2015 06:40
-
-
Save yohhoy/fbbc04721ad56f08693f to your computer and use it in GitHub Desktop.
convert from hex text to binary
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
#!/usr/bin/env python3 | |
import sys | |
import struct | |
if len(sys.argv) != 3: | |
print("Usage: {} <source> <target>".format(sys.argv[0])) | |
quit() | |
with open(sys.argv[1]) as f: | |
hex = f.read() | |
with open(sys.argv[2], 'wb') as f: | |
for h in hex.split(): | |
f.write(struct.pack('B', int(h, 16))) | |
print(f.tell()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment