Skip to content

Instantly share code, notes, and snippets.

Created Dec 8, 2011
What would you like to do?
Create array from binary file
import sys
import textwrap
s=open(sys.argv[1], 'rb').read().encode("hex").upper()
t=",".join(["0x"+x+y for (x,y) in zip(s[0::2], s[1::2])])
print "const unsigned char data[] = {\n\t%s\n};"%" \n\t".join(textwrap.wrap(t,80))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment