Skip to content

Instantly share code, notes, and snippets.

@magnusstubman
Created September 28, 2020 08:57
Show Gist options
  • Save magnusstubman/0783e124f38ae9317811ee53f8354319 to your computer and use it in GitHub Desktop.
Save magnusstubman/0783e124f38ae9317811ee53f8354319 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import sys
import fileinput
h = bytes(sys.stdin.buffer.read()).hex()
n = 2
output = ''
print('buf = (b"', end='')
count = 0
for e in [h[i:i+n] for i in range(0, len(h), n)]:
b = "\\x" + e
if count < 16:
count = count + 1
print(b, end='')
else:
count = 1
print('" +')
print(' b"' + b, end='')
print('")')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment