bin2hex.py
bin2hex.py
#!/usr/bin/env python # Reads binary data from stdin and converts it into # comma separated hex numbers (suitable e.g. for # inclusion in an array initialiser) written to stdout. import sys, textwrap print "\n".join(textwrap.wrap( ", ".join("0x%02x" % ord(b) for b in sys.stdin.read())))