Skip to content

Instantly share code, notes, and snippets.

@matteyeux
Created November 29, 2022 07:42
Show Gist options
  • Save matteyeux/e459d34de2dd6badd7b505edffd08aa6 to your computer and use it in GitHub Desktop.
Save matteyeux/e459d34de2dd6badd7b505edffd08aa6 to your computer and use it in GitHub Desktop.
import sys
if len(sys.argv) != 2:
print("usage: hex.py [file]")
sys.exit(1)
filename = sys.argv[0]
with open(filename,'rb') as f:
buff = f.read()
out_hex = ['{:02X}'.format(b) for b in buff]
[print(f"0x{i}", end=', ') for i in out_hex]
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment